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’); […]