Skip to main content

Blockchain

The blockchain is the distributed database that stores the data of the network. Transaction data, smart contracts and tokens are stored on the blockchain. In order to execute functions in smart contracts we use the ContractFunction class; It is the basis of any operation on the blockchain.

Use a method

To define the use of a method we create an instance of ContractFunction passing it the name of the method.

const method = new ContractFunction('burn');

Additionally, if we want to have better compatibility with a particular contract, we can send the type of asset in which we are executing the method as a second parameter.

const method = new ContractFunction('burn', AssetType.NFT);

Add method inputs

The addInput method allows us to add inputs to the method. The inputs are the parameters that the method receives. To add an input we use the addInput method and pass it the name of the input and the type of data it receives.

method.addInput('tokenId', 1);

Method Options

As a third optional parameter we can send an options object.

const method = new ContractFunction(
"burn",
AssetType.NFT,
new ContractFunctionOptions(new Gas("100"))
);