Avatar
0
monkey Enlightened
monkey Enlightened
Blockchain: Chuyển eth từ wallet address vào contract address
Làm thế nào để chuyển eth từ 1 wallet address vào 1 contract address?
  • Answer
blockchain contract transfer
Remain: 5
1 Answer
Avatar
monkey Enlightened
monkey Enlightened
Code javascript:

async function transferBNBToContract() {
    const nonce = await web3.eth.getTransactionCount(account.address, 'latest');
    const transaction = {
     'to': contractAddress,
     'value': 1000000000000000,
     'gas': defaultGasLimit,
     'nonce': nonce,
    };
   
    const transferTransaction = await web3.eth.accounts.signTransaction(transaction, account.privateKey);
    web3.eth.sendSignedTransaction(transferTransaction.rawTransaction).then(console.log);
}

Tham khảo:

  1. https://solidity-by-example.org/sending-ether/
  2. https://ethereum.stackexchange.com/questions/62621/transfer-from-contract-address
  3. https://betterprogramming.pub/how-to-send-ethereum-transactions-using-web3-d05e0c95f820
  • 0
  • Reply