Skip to main content

Write Transactions

Writing transactions to the blockchain requires you to connect to a wallet first.

Feature Functions

The SDK includes a comprehensive set of helper functions to write transactions to your smart contract.

Any Prebuilt contract or contract built using ContractKit has access to these functions in the SDK.

// Each of the below calls will prompt the user to approve a transaction:
var result1 = await contract.ERC721.Burn("0"); // ERC721
var result2 = await contract.ERC1155.Claim("0", 1); // ERC1155
var result3 = await contract.ERC20.Transfer("<to-wallet-address>", "<amount-of-tokens>"); // ERC20

Function By Name

Call any contract function using the Write method and providing any required arguments:

var result = await contract.Write("functionName", arg1, arg2);

Checking Transaction Status

The TransactionResult returned by any transaction contains an isSuccessful function that returns a bool:

var result = await contract.Write("functionName", arg1, arg2);
if (result.isSuccessful())
{
// Transaction was successful
}
else
{
// Transaction failed
}