Trx
This is a generic method for invoking JSON RPC's eth_sendTransaction
with Ethers.js. Use this method to create a transaction that invokes a smart contract method. Returns an Ethers.js TransactionResponse
object.
address
(string) The Ethereum address the transaction is directed to.method
(string) The smart contract member in which to invoke.[parameters]
(any[]) Parameters of the method to invoke.[options]
(CallOptions) Options to set foreth_sendTransaction
, (as JSON object), and Ethers.js method overrides. The ABI can be a string optional ABI of the single intended method, an array of many methods, or a JSON object of the ABI generated by a Solidity compiler.RETURN
(Promise<any>) Returns an Ethers.jsTransactionResponse
object or an error object if the transaction failed.
const oneEthInWei = '1000000000000000000';
const sEthAddress = '0x4ddc2d193948926d02f9b1fe9e1daa0718270ed5';
const provider = window.ethereum;
(async function() {
console.log('Supplying ETH to the Belugas Loan...');
// Mint some aBNB by supplying ETH to the Belugas Loan
const trx = await Belugas.eth.trx(
sEthAddress,
'function mint() payable',
[],
{
provider,
value: oneEthInWei
}
);
// const result = await trx.wait(1); // JSON object of trx info, once mined
console.log('Ethers.js transaction object', trx);
})().catch(console.error);
Last updated