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 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

sendRawTransaction error in web3.js

i am trying to send a request for my contract function to web3: my code snippets is here: const W3 = require(‘web3’); const express = require(‘express’); const ethTx = require(‘ethereumjs-tx’).Transaction; let web3, contractAddress, contractABI, contract, fromAdd, myData, estGasPrice; function connectContract(){ const provider = new W3.providers.HttpProvider(`${process.env.INFURA_ROPSTEN_ADDRESS}${process.env.INFURA_ROPSTEN_KEY}`); web3 = new W3(provider); contractAddress = process.env.LBT_CONTRACT_ADDRESS; contractABI =JSON.parse(process.env.LBT_CONTRACT_ABI); contract […]

Categories
Cryptocurrency Ethereum Mastering Development

Transaction won’t be mined / Failed signing of transaction

I’m trying to send a transaction that writes somesthing on ethereum(kovan) but it seems my transaction is not mined and probably not even send to the network? All my view requests to ethereum work, so my guess is that there is a problem with the signing of my transaction? After firing my script I receive […]

Categories
Cryptocurrency Development Ethereum

Getting error -> unexpected token. You may need an appropriate loader to handle this file type

root@kali:~/Documents/oraclize-test# npm run dev truffle-oraclize-api@0.0.2 dev /root/Documents/oraclize-test webpack-dev-server ERROR in ./app/javascripts/app.js Module parse failed: /root/Documents/oraclize-test/app/javascripts/app.js Unexpected token (124:0) You may need an appropriate loader to handle this file type. | }) | } | @ multi (webpack)-dev-server/client?http://localhost:8081 ./app/javascripts/app.js webpack: Failed to compile. APP.JS // Import the page’s CSS. Webpack will know what to do with […]

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 […]

Categories
Development

Transaction failed upon updation of contract state variable

I have deployed my following contract to ropsten network, making some transaction ok. when I consumed all my tokens (totalSupply) and confirmed it (showing totalSupply = 0) . After confirmation, i call setTotalSupply. But when i called setTotalSupply (through making trx with value =0, value=100gwei or without value parameter .. all are in vein… my […]

Categories
Development Java Javascript

State Variable of solidity Contract could not be updated through JavaScript

I have following contract and just want to update its state variable values i.e. totalSupply. But when I try to attempt this task through JavaScript code (given below) by calling its function i.e. setTotalSupply, tts values is not updated. pragma solidity 0.5.1; contract MyContract { uint256 totalSupply; mapping(address => uint256) public balances; address owner; constructor(address […]