Categories
Cryptocurrency Ethereum Mastering Development

transfer hash verification on contract side

I want to verify if message-hash has a particular contract method. Like below web3 code generates a rawTransaction having,messageHash,v, r, s, rawTransaction let rawTransaction = { ‘from’: fromAddress, ‘gasLimit’: web3js.utils.toHex(310000), ‘to’: contractAddress, ‘gasPrice’: web3js.utils.toHex(20 * 1e9), ‘value’: “0x0”, ‘data’: contract.methods.transfer(toAddress, amount).encodeABI(), ‘nonce’: web3js.utils.toHex(count), } web3js.eth.accounts.signTransaction(rawTransaction, PK); i.e if message hash from the above signed transaction […]

Categories
Cryptocurrency Ethereum Mastering Development

signing transaction in web3 is not returning msgHash

I am trying to write provble_transfer where owner can pay gas fee for the transaction. Below is the code for signing transaction to my test contact. let rawTransaction = { ‘from’: fromAddress, ‘gasPrice’: web3js.utils.toHex(20 * 1e9), ‘gasLimit’: web3js.utils.toHex(3000000), ‘to’: contractAddress, ‘value’: “0x0”, ‘data’: contract.methods.transfer(toAddress, amount).encodeABI(), ‘nonce’: web3js.utils.toHex(count), “chainId”: 4 }; let privateKey = Buffer.from(requestPrivateKey, ‘hex’); […]

Categories
Cryptocurrency Ethereum Mastering Development

ERC20 Transaction failing due to invalid nonce value

I am trying to send an erc20 transaction but I keep getting an error telling me that the account I’m sending the transaction from has a nonce value of 1 while the tx has a nonce value of 31613. I am running ganache-cli on the terminal and compiled + deployed my smart contract using the […]

Categories
Cryptocurrency Development Ethereum

Get transaction status

There is a code, the essence is this: I need to check the account balance for erc20 tokens, and if the balance is not zero, I need to send eth from another account to this one, after eth reaches the account, I need to send erc20 tokens to another account . How then can I […]

Categories
Cryptocurrency Development Ethereum

Get transaction status

There is a code, the essence is this: I need to check the account balance for erc20 tokens, and if the balance is not zero, I need to send eth from another account to this one, after eth reaches the account, I need to send erc20 tokens to another account . How then can I […]

Categories
Cryptocurrency Development Ethereum

Get an error: insufficient funds for gas * price + value

I need to send erc20 tokens from one address to another, provided that the token balance is not empty. I check the balance as follows: const balance = contractInstance.methods.balanceOf (walletAddress) .call (function (err, result) {        //console.log(err) if (result> 0) { console.log (“result”) } If there are 3 tokens on the account, then the result variable […]

Categories
Cryptocurrency Development Ethereum

Error sending erc20 tokens

I try to send erc20 tokens in this way var Tx = require(‘ethereumjs-tx’); var Web3 = require(‘web3’) var web3 = new Web3(new Web3.providers.HttpProvider(‘https://mainnet.infura.io/v3/2a7d7b55629d44119f069a9239ea96fd’)) // set token source, destination and amount var myAddress = “” var toAddress = “” var amount = web3.utils.toHex(1e16) // get transaction count, later will used as nonce web3.eth.getTransactionCount(myAddress).then(function(v){console.log(v); count = v}) […]