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

Transaction to contract from web3 not working but working from metamask

I have a method in contract to increase totalSupply and only owner can call it. function addTokenToTotalSupply(uint _value) onlyOwner public { require(_value > 0); balances[owner] = balances[owner].add(_value); totalSupply = totalSupply.add(_value); } When I try this method from meta mask using owner account it works fine but when I use web3 code it returns transaction hash […]

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 balance Storage Address key – how to tell which key belongs to which wallet address

I am trying to derive changes of account storage by mapping accounts (here, the accounts represent the key address in the ERC20 balances mapping mapping(address => uint256)) to their corresponding storage keys from a parity transaction trace. An example trace (fetched through web3.js) of transaction https://etherscan.io/tx/0x210cfe3d3b62f415ed0327a3c6177086df4937b6280031255360b6d137308554 is: { ‘output’: ‘0x’, ‘stateDiff’: { ‘0x52bc44d5378309ee2abf1539bf71de1b7d7be3b5’: { ‘balance’: […]

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 Ethereum Mastering Development

What does “Time” in the Geth VM Trace Transaction refer to?

I’m new to Ethereum world, and I need some declaration, I just found Geth VM Trace Transaction { “type”: “CALL”, “from”: “0x6f1e5fc933898859686a4d39f4430316be589f5e”, “to”: “0xb61e9cb66cb5b2ca9d6f4db003c364d0698cac33”, “value”: “0x0”, “gas”: “0x5b3770”, “gasUsed”: “0x2b03”, “input”: “0xfc62b26d00000000000000000000000000000000000000000000000000000000000000400000000000000000000000001c67eacc46c5c3727b4300597acc07fe4a9ad6c5000000000000000000000000000000000000000000000000000000000000001146313a32303a45353a41433a36473a4131000000000000000000000000000000”, “output”: “0x”, “time”: “5.0133ms” } My question: What the time”: “5.0133ms is referring to? Is it transaction execution time, or time spent to […]

Categories
Cryptocurrency Ethereum Mastering Development

Etherscan api: how to get transaction fee?

For example: open this https://etherscan.io/tx/0xcb1e3530950cf2c43a307bcb5645ae71a12c76a60831617badd04aea3efe68aa It’s a random one I see these infos on webpage: Gas Limit: 136,500 Gas Used by Transaction: 35,531 (26.03%) Gas Price: 0.000000008 Ether (8 Gwei) Transaction Fee: 0.000284248 Ether ($0.05) I know that fee = gas_price x used_gas => 0.000000008 x 35,531 = 0.000284248 eth Perfect. I am interested in […]

Categories
Cryptocurrency Development Ethereum

Get each transactions from response of txpool.getContent()

I’m trying to get each transactions from response of txpool.getContent(). The response structure is here. > pending: { ‘0x0000000186c96Ab17A967d7A3033db82efcA587B’: { ’11’: [Object] }, ‘0x00000004888f25bb2a792e78D5a6dF392d59e140′: { ’39’: [Object] }, ‘0x000000057c695b6Af389Ff5b7542c7e01333981A’: { ’13’: [Object] }, ‘0x000000084115EdEB2c9484b490F7AC89F8980E5F’: { ’12’: [Object] }, ‘0x000000086aD594b50486A68246D506E5DE24EBD8’: { ‘12087’: [Object], ‘12088’: [Object], ‘12089’: [Object], ‘12090’: [Object], ‘12091’: [Object], ‘12092’: [Object], ‘12093’: [Object], ‘12094’: […]

Categories
Cryptocurrency Development Ethereum

geth is returning call trace but does not count balance change

I send this command to my geth (I’m sure anyone’s Geth would return the same): curl host:8545 -X POST –header ‘Content-type: application/json’ –data ‘{“jsonrpc”:”2.0″, “method”:”debug_traceTransaction”, “params”:[“0x72c2f85bde52b310436ab52159c9a2ad0762d63cb66061a1605ff6295bc96b67”, {“tracer”: “callTracer”, “timeout”: “20m”}], “id”:1}’ This returns the following traces: { “jsonrpc”: “2.0”, “id”: 1, “result”: { “type”: “CALL”, “from”: “0x741b513c8508e3119174eb403315ea96d3dccf67”, “to”: “0xf058241b1fd6bc0bfb01ebdacb19a71a8345f22f”, “value”: “0x0”, “gas”: “0x36238”, “gasUsed”: “0x64e9”, […]

Categories
Cryptocurrency Development Ethereum

Send transaction with locked contract -> Error: insufficient funds for gas * price + value

I’m trying to send a transaction for a token with a locked contract. I’m doing this to find out when this contract will be open. So I’m expecting to get some kind of error like “ERC-20 Token Transfer Error (Unable to locate corresponding Transfer Event Logs), Check with Sender” or something, but I get this […]