VICTION Chain Integration
VICTION is an EVM-compatible public blockchain. So you can use TomoChain JSON-RPC APIs similar as in Ethereum.EVM compatible libraries such as Web3 library can be fully reused in integration to create a wallet, check wallet balances, or create/send transactions. All you need is to connect to TomoChain's RPC public endpoint. This tutorial will guide you the steps to connect to TomoChain Testnet/Mainnet.
Connect to TomoChain's public RPC endpoint
Create a wallet
Generate an account object with private key and public key.
Example
Check wallet balances
Get account balance.
Example
Create transaction
Send transaction to the network. You need to unlock wallet before using this function.
Parameters
Object - The transaction object to send:
from
-String|Number
: The address for the sending account. Uses the web3.eth.defaultAccount property, if not specified. Or an address or index of a local wallet in web3.eth.accounts.wallet.to
-String
: (optional) The destination address of the message, left undefined for a contract-creation transaction.value
-Number|String|BN|BigNumber
: (optional) The value transferred for the transaction in wei, also the endowment if it’s a contract-creation transaction.gas
-Number
: (optional, default: To-Be-Determined) The amount of gas to use for the transaction (unused gas is refunded).gasPrice
-Number|String|BN|BigNumber
: (optional) The price of gas for this transaction in wei, defaults to web3.eth.gasPrice.data
-String
: (optional) Either a ABI byte string containing the data of the function call on a contract, or in the case of a contract-creation transaction the initialisation code.nonce -
Number
: (optional) Integer of a nonce. This allows to overwrite your own pending transactions that use the same nonce.
callback
-Function
: (optional) Optional callback, returns an error object as first parameter and the result as second.
Example
Sign data
After unlock a wallet, you can sign some data
Parameters
1.
String
- Data to sign. If String it will be converted usingweb3.utils.utf8ToHex
.2.
String|Number
- Address to sign data with. Or an address or index of a local wallet inweb3.eth.accounts.wallet
.3.
Function
- (optional) Optional callback, returns an error object as first parameter and the result as second.
Example
Check transaction status
The receipt is not available for pending transactions and returns null.
Parameters
String - The transaction hash.
Function - (optional) Optional callback, returns an error object as first parameter and the result as second.
Returns
Promise returns Object - A transaction receipt object, or null when no receipt was found:
status
-Boolean
:TRUE
if the transaction was successful,FALSE
, if the EVM reverted the transaction.blockHash
32 Bytes -String
: Hash of the block where this transaction was in.blockNumber
-Number
: Block number where this transaction was in.transactionHash
32 Bytes -String
: Hash of the transaction.transactionIndex
-Number
: Integer of the transactions index position in the block.from
-String
: Address of the sender.to
-String
: Address of the receiver. null when its a contract creation transaction.contractAddress
-String
: The contract address created, if the transaction was a contract creation, otherwise null.cumulativeGasUsed
-Number
: The total amount of gas used when this transaction was executed in the block.gasUsed
-Number
: The amount of gas used by this specific transaction alone.logs
-Array
: Array of log objects, which this transaction generated.
Irreversible blocks
In normal case, you can wait for 60 confirmations, then checking block finality via eth_getBlockFinalityByNumber
or eth_getBlockFinalityByHash
API:
If result
>= 75, it means the block with the input hash is finalized, thus irreversible.
How does TomoChain smart contract work?
TomoChain supports Solidity compiler version <= 0.5.0
Does TomoChain support multi-signature wallets?
Yes. Similar to Ethereum, you can use Gnosis MultiSigWallet.
Last updated