For all Zilliqa Ecosystem Grant related topics. For more information, visit https://forms.gle/Ep1H6d26CaJx2Rxp9.
error:
code: -5
data: null
message: "Account is not created"
const tx = await zilliqa.blockchain.createTransaction(
zilliqa.transactions.new({
version: 1,
toAddr: sendTo,
amount: new BN(sendAmount),
gasPrice: new BN(sendGasPrice),
gasLimit: Long.fromNumber(sendGasLimit),
})
);
error: {code: -26, data: null, message: "CHAIN_ID incorrect"}
id: 1
jsonrpc: "2.0"
// These are set by the core protocol, and may vary per-chain.
// These numbers are JUST AN EXAMPLE. They will NOT WORK on the public testnet
// or mainnet. Please check what they are before proceeding, or your
// transactions will simply be rejected.
const CHAIN_ID = 88;
const MSG_VERSION = 8;
const VERSION = bytes.pack(88, 8);
version
is a decimal conversion of the binary concatenation of both CHAIN_ID
and MSG_VERSION
. You will need to pack them together. You can use the Zilliqa-js util package to do so.const { BN, Long, bytes, units } = require('@zilliqa-js/util’);
…
const CHAIN_ID = 62;
const MSG_VERSION = 1;
const VER = bytes.pack(CHAIN_ID, MSG_VERSION);
…
let tx = zilliqa.transactions.new({
version: VER,
toAddr: 'f8c429e096abaabf43257728894d88f1142501a1',
// Note all transactional values has to be converted to Qa (the smallest accounting unit) when using the Zilliqa protocol.
// 1 Qa is 10^-12 Zil.
amount: units.toQa('1000000', units.Units.Zil), // Sending an amount in Zil and converting the amount to Qa.
gasPrice: units.toQa('1000', units.Units.Li), // Minimum gasPrice in Li. Convert to Qa.
gasLimit: Long.fromNumber(1),
});
const CHAIN_ID = 1 // MainNet ID
const MSG_VERSION = 1 // First transaction payload version
const version = (( CHAIN_ID << 16 ) + MSG_VERSION).toString(); // returns 65537
1 zil
, after amount: units.toQa(sendAmount, units.Units.Zil),
it becomes 1000000000000
, it means I send out 1000000000000 zil
transactions
{"id":1,"jsonrpc":"2.0","method":"CreateTransaction","params":[{"version":4063233,"toAddr":"399667D8c48cefBF1972F0C12eB49c8Ab995dd97","nonce":4,"pubKey":"0325304d408cf4b3e0eb9bba264c7eb78a2f54de65b608d07872f827af2d0a9b4b","amount":"1000000000000","gasPrice":"1000000000","gasLimit":"1","code":"","data":"","signature":"1d36bf20aea6cb59e224291d4cc2a07bdbe6d0c220ed3525d31bea0162f0bf1c764ed4f020c7036272059f5378aa86beac21eef4cdabe2ae90b91384eae9a227"}]}