@harmony-js/transaction provides the functions to build transactions
@harmony-js/transaction
Develop can use this package to:
const { Harmony } = require('@harmony-js/core'); const { ChainID, ChainType } = require('@harmony-js/utils'); const { BN } = require('@harmony-js/crypto'); const hmy = new Harmony( 'http://localhost:9500', { chainType: ChainType.Harmony, chainId: ChainID.HmyLocal, }, );
const txn = hmy.transactions.newTx({ to: 'one166axnkjmghkf3df7xfvd0hn4dft8kemrza4cd2', value: '10000', gasLimit: '210000', shardID: 0, toShardID: 0, gasPrice: new hmy.utils.Unit('100').asGwei().toWei(), });
Transaction Parameters
// interface TxParams id: string; from: string; to: string; nonce: number | string; gasLimit: number | string | BN; gasPrice: number | string | BN; shardID: number | string; toShardID: number | string; data: string; value: number | string | BN; chainId: number; rawTransaction: string; unsignedRawTransaction: string; signature: Signature; receipt?: TransasctionReceipt;
Transaction Receipt
// interface TransasctionReceipt transactionHash: string; transactionIndex: string; blockHash: string; blockNumber: string; // 11 from: string; to: string; gasUsed: string; cumulativeGasUsed: string; // 13244 contractAddress?: string | null; // or null, if none was created logs: any[]; logsBloom: string; // 256 byte bloom filter v: string; r: string; s: string; responseType?: string; byzantium?: boolean; status?: string; // post Byzantium will return `0x0` or `0x1` root?: string; // pre Byzantium will return `root`
Generated using TypeDoc
About this package
@harmony-js/transaction
provides the functions to build transactionsDevelop can use this package to:
How to use this package
Step 1: create a Harmony Instance
const { Harmony } = require('@harmony-js/core'); const { ChainID, ChainType } = require('@harmony-js/utils'); const { BN } = require('@harmony-js/crypto'); const hmy = new Harmony( 'http://localhost:9500', { chainType: ChainType.Harmony, chainId: ChainID.HmyLocal, }, );
Step 2: build a transaction
const txn = hmy.transactions.newTx({ to: 'one166axnkjmghkf3df7xfvd0hn4dft8kemrza4cd2', value: '10000', gasLimit: '210000', shardID: 0, toShardID: 0, gasPrice: new hmy.utils.Unit('100').asGwei().toWei(), });
some important information
Transaction Parameters
// interface TxParams id: string; from: string; to: string; nonce: number | string; gasLimit: number | string | BN; gasPrice: number | string | BN; shardID: number | string; toShardID: number | string; data: string; value: number | string | BN; chainId: number; rawTransaction: string; unsignedRawTransaction: string; signature: Signature; receipt?: TransasctionReceipt;
Transaction Receipt
// interface TransasctionReceipt transactionHash: string; transactionIndex: string; blockHash: string; blockNumber: string; // 11 from: string; to: string; gasUsed: string; cumulativeGasUsed: string; // 13244 contractAddress?: string | null; // or null, if none was created logs: any[]; logsBloom: string; // 256 byte bloom filter v: string; r: string; s: string; responseType?: string; byzantium?: boolean; status?: string; // post Byzantium will return `0x0` or `0x1` root?: string; // pre Byzantium will return `root`