Skip to main content

Simple Contract Call

The following example shows how to do a simple contract call with Beacon.


The beacon-sdk itself does not do any type checking on the parameters you pass. Use taquito if you don't want to construct the parameters yourself.

The wallet will process and validate the operation. If there are any errors, they have to be displayed in the wallet. run_operation errors can optionally be sent back to the dApp as well.

Live Editor
import { DAppClient, TezosOperationType } from "@airgap/beacon-sdk";

// Create a new DAppClient instance
const dAppClient = new DAppClient({ name: "Beacon Docs" });

const activeAccount = await dAppClient.getActiveAccount();
if (activeAccount) {
  // User already has account connected, everything is ready
  // You can now do an operation request, sign request, or send another permission request to switch wallet
  console.log("Already connected:", activeAccount.address);
} else {
  const permissions = await dAppClient.requestPermissions();
  console.log("New connection:", permissions.address);

const tokenId = "925";

// Setting the color of TzButton is only possible if you are currently the leader and own a color
// So this call will likely fail
try {
  const result = await dAppClient.requestOperation({
    operationDetails: [
        kind: TezosOperationType.TRANSACTION,
        amount: "0",
        destination: TZ_BUTTON_COLORS_CONTRACT,
        parameters: {
          entrypoint: "set_color",
          value: {
            int: tokenId,

} catch (error) {
    `The contract call failed and the following error was returned:`,