Skip to main content

Usage

await callSmartContract({
  contractAddress: '0x1234567890123456789012345678901234567890',
  functionName: 'transfer',
  functionParams: [
    '0x0987654321098765432109876543210987654321',
    '1000000'
  ],
  value: '0'
});

Parameters

type CallSmartContractInput {
  contractAddress: '0x${string}';
  functionName: string;
  functionParams: string | number[];
  value: string;
  contractStandard?: ContractStandard;
  chainId?: ChainId;
}
contractAddress
0x${string}
required
The address of the smart contract to interact with.
functionName
string
required
The name of the smart contract function to call.
functionParams
string | number[]
required
The parameters to pass to the smart contract function. Should be an empty array if no parameters are needed.
value
string
required
The amount of native currency (ETH, POL, etc.) to send with the transaction. Specify ‘0’ if no native token is transferred.
contractStandard
ContractStandard
The contract standard if any (e.g., ‘ERC20’).
chainId
ChainId
If your Mini App supports multiple chains, you can specify the chain id to use.

Returns

type CallSmartContractResponse = {
  result: TransactionResult.SUCCESS;
  data: {
    txHash: string;
  };
} | {
  result: TransactionResult.FAILED;
  error: MiniAppError;
} | {
  result: TransactionResult.CANCELLED;
}

Returns

result
TransactionResult
The result of the smart contract call attempt.
  • SUCCESS: The smart contract call was successful.
  • FAILED: The smart contract call failed.
  • CANCELLED: The smart contract call was cancelled by the user.
data
object
Contains the transaction hash of the smart contract call transaction. Only present when the result is SUCCESS.
  • txHash: The transaction hash.
error
MiniAppError
Contains the error information when the smart contract call fails. Only present when the result is FAILED.
  • message: The error message.
  • code: The error code.

Demo