Execute Functions
A function changing a state requires a transaction. The transaction needs to be signed by an origin before it is added to the blockchain.
Example Conditions
Source Code
The VTHO contract's source code is available on GitHub:
https://github.com/vechain/thor/blob/f58c17ae50f1ec8698d9daf6e05076d17dcafeaf/builtin/gen/energy.sol (opens in a new tab)
Contract address
The public VTHO contract is used. Address is identical on Test and MainNet.
0x0000000000000000000000000000456E65726779
ABI
Definition of the transfer
that transfers VTHO to another address.
{
constant: false,
inputs: [
{
name: "_to",
type: "address"
},
{
name: "_amount",
type: "uint256"
}
],
name: "transfer",
outputs: [
{
name: "success",
type: "bool"
}
],
payable: false,
stateMutability: "nonpayable",
type: "function"
}
Function definition
function transfer(address _to, uint256 _amount) public {}
Connex Example
const clause = connex.thor
.account(CONTRACT_ADDRESS)
.method(abi)
.asClause(address, 0);
const result = await connex.vendor
.sign("tx", [clause])
// .delegate(DELEGATE_URL) // only if fee delegation is used
.request();
console.log(result)