Smart Contract
Smart contract is a key feature of WELUPS network. It’s easy to creating and interacting with smart contracts through Welups SDK.
Calling smart contract
There are two types of smart contract calls: const call and trigger call.
Simply, a const call returns result immediately once and no need to sign or broadcast.
Trigger call is a type of system contract call, needs signing and broadcasting. It fetches the result through the API.
You may see the functions of a specified contract by ContractFunction.toString()
, then you can construct a Function
object to make a constant/trigger call.
Get contract
Get a Contract object from the address.
PARAMS
1. contractAddress(String)
The address of a smart contract.
RETURN
A Contract object.
THROW
Throws if the given contract address does not match any.
Example :
The result is:
Trigger call
Make a trigger call. Trigger calls require signature and broadcasting. Refer to RPC_APIs for the signing and broadcasting functions.
The first half of the trigger call process is similar to the const call.
You can easily set feeLimit, memo
and other common attributes via the TransactionBuilder
PARAMS
1. ownerAddr(String)*
The caller’s address.
2. contractAddr(String)*
The contract’s address.
3. function(Function)*
The exact function you are calling, you can find the example in the triggerCallDemo
.
RETURN
A TransactionBuilder object, for easily setting memos, feelimit, Etc.
THROW
Throws if the function does not match any in the smart contract.
Example:
======== Result ======== 0d2b6a4a7d52e0775da63443e285010441ab9490cf57c47c097ff85b79aff3e0
constantCall
Make a constant call, without broadcasting.
PARAMS
1. ownerAddr(String)*
The caller’s address.
2. contractAddr(String)*
The contract’s address.
3. function(Function)*
The exact function you are calling, you can find the example in the triggerCallDemo
.
RETURN
A TransactionExtention object
THROW
Throws if the function does not match any in the smart contract.
Last updated