Deploy custom Smart Contracts
EVM Based Protocols (Ethereum-virtual-machine)
const sdk = new CryptumSdk({
environment: 'testnet',
apiKey: 'YOUR-API-KEY'
})Call smart contract method
sdk.contract.callMethod(opts)
sdk.contract.callMethod(opts)Call a method of a smart contract and receive its value without creating a transaction in the blockchain.
opts.contractAddress(string) (required) - contract address of the smart contract.opts.contractAbi(array) (required) - json interface of the method (for more info on contract ABI).opts.method(string) (required) - smart contract method.opts.params(array) - parameters to be passed to the method.opts.protocol(string) (required) - EVMs only.
const { result } = await sdk.contract.callMethod({
contractAddress: '0x2B751008...6a763e72788Db9Ca',
contractAbi: [
{
constant: true,
inputs: [],
name: 'message',
outputs: [
{
internalType: 'string',
name: '',
type: 'string',
},
],
payable: false,
stateMutability: 'view',
type: 'function',
},
],
method: 'message',
params: [],
protocol: 'CELO'
})
console.log(result)
// Result value from smart contract methodCreate smart contract call transaction
sdk.contract.callMethodTransaction(opts)
sdk.contract.callMethodTransaction(opts)Call a method of a smart contract that will generate a transaction in the blockchain.
opts.wallet(Wallet) (required) - wallet calling the smart contract and signing this transaction.opts.contractAddress(string) (required) - contract address of the smart contract.opts.contractAbi(array) (required) - json interface of the method (for more info on contract ABI).opts.method(string) (required) - smart contract method.opts.params(array) - parameters to be passed to the method.opts.protocol(string) (required) - EVMs only.
Deploy a smart contract
sdk.contract.deploy(opts)
sdk.contract.deploy(opts)Deploy a smart contract source code written in Solidity to the blockchain.
opts.wallet(Wallet) (required) - wallet deploying the smart contract.opts.contractName(string) (required) - main contract name. There could be many contracts in the source code, but you must specify which one is the main one to initialize it after deployment.opts.params(array) (required) - parameters to be passed to the constructor of the main contract.opts.source(string) (required) - source code of the contract encoded in UTF-8.opts.protocol(string) (required) - EVMs only.
Last updated
