New answers tagged

0

tabrizi How to use for erc20 token for the same please help to solve


0

@Pranav correctly indicates that there seems to be an issue with garbage collection and disposal. The simplest method to solve the issue for me was to create a new browser environment: Close every open tab on every window in current browser; Restart browser; Close any tabs which open up; Restart browser (skip if no tabs open in step 3; Open Metamask and ...


0

Your issue may comes from line var accounts= await web3.eth.getAccounts(); It should be var accounts= await window.web3.eth.getAccounts(); instead. In your code accounts[] is undefined, so var option={from: accounts[0] }; throws an error. One more point, "option" is a javascript reserved keyword. Use "options" instead for instance.


0

If you want to call a method without the abi file you can do it by encoding the signature. https://github.com/ethereum/web3.js/blob/5829347e537473b6de2d9fda2c830f2be6f47968/docs/web3-eth-abi.rst#encodefunctionsignature Once you've encoded it you can sign the transaction and submit it manually.


0

I ran into this same issue when running a react truffle box, compiler 0.7.0. After using truffle develop I forgot to actually migrate the contract. I'm only a few days into learning but I enjoyed the lesson. Perhaps those who find themselves here will avoid this mistake :)


0

Can you try replacing web3.setProvider(new Web3.providers.WebsocketProvider('https://ropsten.infura.io/')); With web3.setProvider(new Web3.providers.WebsocketProvider('wss://ropsten.infura.io/')); It might be a websocket issue as web3 1.0 doesn't support events for http.


1

solved this way: const compile = require('../compile'); const interface = JSON.parse(compile).contracts["Inbox.sol"].Inbox.abi; const bytecode = JSON.parse(compile).contracts["Inbox.sol"].Inbox.evm.bytecode.object;


2

You cannot get the private key from web3.eth.getAccounts() directly, but there's a few workarounds to do this with ganache: Specify a mnemonic phrase with the -m option, e.g. ganache-cli -m "stereo consider quality wild fat farm symptom bundle laundry side one lemon", this will derive private keys from the mnemonic phrase (with the derivation path ...


0

The suitable answer to the date: class TransactionChecker { constructor(address) { this.address = address.toLowerCase(); this.web3 = new Web3("https://mainnet.infura.io/v3/60968ff3b2f84a0ebdff7a993f4d080b"); } async checkBlock() { let block = await this.web3.eth.getBlock('latest'); let number = block.number; let ...


1

I had a number of things wrong: To add to @clement's answer, tx should be: tx = { nonce: nonce, gasPrice: gasPrice, gasLimit: gasLimit, to: contractAddress, value: value, data: contractData, chainId : 1, }); //add chainId I also needed to create an account object: let acc = await web3.eth.accounts.wallet.add(signingPrivateKey) ...


1

The tx object is the following : tx = { nonce: nonce, gasPrice: gasPrice, gasLimit: gasLimit, to: contractAddress, value: value, data: contractData, }); I think what you are looking for is the data parameter which is obtained using the enoceABI() web3 function (cf https://web3js.readthedocs.io/en/v1....


0

This error comes from the Class EnsResolver as shown above "org.web3j.ens.EnsResolutionException" and it is saying that the node you are connected to does not have a Public Resolver installed in that could provide an access to the API. "Your node does not Provide an access to a valid public resolver in order to access other API methods." ...


0

This problem is really stupid: importRawKey is not expecting "0x" at the start of the hex string. So if you have privateKey = "0xffffffffffffff" // etc pass = "blah" Try chopping off the first 2 characters with .slice(2): web3.eth.personal.importRawKey(privateKey.slice(2), pass)


0

The experiment (takes like 15 sec on my i5 processor) for(let i=0; i<1000000; ++i) { x = web3.utils.randomHex(32); if(x.replace(/x0*/, "x") != web3.utils.toHex(web3.utils.toWei(web3.utils.fromWei(x)))) { console.log(x); break; } } shows that in this case rounding errors do not happen.


0

I have implemented the above method with python, and it feels about the same as the computing power of the whole network hashrate! eth = create_rpc("ETH") current_height = int(eth.eth_blockNumber(), 16) sampleSize = 200 current_block = eth.eth_getBlockByNumber(hex(current_height), False) pre_height = eth.eth_getBlockByNumber(hex(current_height - ...


0

You must to encrypt your message by web3.utils.sha3 instead of web3.utils.utf8ToHex.


0

My bad: My program pulled in the Mainnet contract address from the json. This overwrote the correct address I posted above it. I forgot I had that address definition buried there, as it's redundant.


0

The contract address will be different on different networks. This is why the call fails.


1

Try specifying explicitly your private network informations such as in this example from the web3js documentation : web3.eth.accounts.signTransaction({ to: '0xF0109fC8DF283027b6285cc889F5aA624EaC1F55', value: '1000000000', gas: 2000000 common: { baseChain: 'mainnet', hardfork: 'petersburg', customChain: { name: 'custom-chain', chainId: 1, ...


1

Value should be in hex format. Note: in some updated MetaMask installation, it seems the injected web3 has not the utils package anymore, so you may need to use web3.toWei instead. const myParameters = { from: "0x5c0bC92f7d26F7AD821408e2B1774FC96858C691", to: "0x6cC5550509CC3a66Df97Efa42B866A058e12ADE2", value: parseInt(web3....


0

You may by the following: Step-I: on your console write "node" and then enter ~/../currentDir> node Then: >var Web3 = require("web3"); >console.log(Web3.version); Output: '1.2.11' //version


0

Update for 2020: It's just Web3.version E.g. console.log(Web3.version);


-1

You may go by latest form: var Web3 = require("web3"); var url = 'https://ropsten.infura.io'; var web3 = new Web3(url); var address = '0x8690F1feff62008A396B31c2C3f380bD0Ca6d8b8'; var balance = web3.eth.getBalance(address); var wallet = web3.eth.toWei(balance, 'ether'); Here, I tried to show two changes, i.e, 1. no use of 'new Web3.providers....


1

I used: Provide the prefixed Ethereum ECDSA signature* of the hex encoded file using the person's Ethereum address. *As per sign(keccak256("\x19Ethereum Signed Message:\n" + dataToSign.length + dataToSign))) (e.g. web3.personal.sign) I think just using "Ethereum ECDSA signature" leaves ambiguity between above and the un-prefixed ...


3

JSON-RPC is not a behaviour of the Ethereum network - Ethereum clients don't talk to each other via JSON-RPC - it's just a notation to encode a remote procedure call that some Ethereum client can interpret as commands sent by the users, and they can respond to those requests in a standard manner. JSON-RPC is easy to implement, it's easy to read and to debug -...


1

Your question assumptions are false, because there are other API protocols like graphQL for Ethereum. Why everyone is using JSON-RPC is because Satoshi chose JSON-RPC for Bitcoin back in 2009. Then everyone followed the suit. Not for a particular reason, but because of cargo culting and so on, though JSON-RPC has some good properties like being curlable and ...


0

You try create new User: User user = new User(name, publicKey); But User constructor does not have arguments: constructor () public { }


1

You can check the current network chain ID like this: console.log(window.ethereum.networkVersion, 'window.ethereum.networkVersion'); And these are the chain IDs for the most used ethereum networks: Mainnet: 1 Kovan: 42 Ropsten: 3 Rinkeby: 4 Goerli: 5


0

Notice that new API is available: // Legacy dapp browsers... if (window.web3 !== undefined) { const provider = new Web3.providers.HttpProvider(window.web3.currentProvider); const web3 = new Web3(provider); } // Modern dapp browsers... if (window.ethereum !== undefined) { const provider = new Web3.providers.HttpProvider(window.ethereum); const ...


0

Try replacing ipfs.add with ipfs.files.add.


0

You're trying to update the state of the contract and in this case it is required that you have to sign transaction. Take a look at web3 sendTransaction method over here. When you take a look at the method you will notice parameter transactionObject include data string which is the function ABI of your smart contract method. You can get function abi by using ...


0

The function has its own this binding, so you cannot access this.state on the parent. To solve this, you can either: Use an arrow function, since they don't provide their own this binding: .on("data", (event) => { console.log(this.state.users); }) Bind the function to the parent's this object: function handleData (event) { console....


0

It's const Tx = require('ethereumjs-tx').Transaction . Here is the exemple from the Github repository : https://github.com/ethereumjs/ethereumjs-tx .


1

In wallets and other Dapp interfaces different tokens and assets are displayed as having decimals. Since the EVM doesn't really support normal decimal datatypes such as floats for example what most ERC20 tokens do is they use integers and instead define a number of decimals (usually 18). So when you receive 1 BAT for example the smart contract will really ...


1

Notice that new API is available: // Legacy dapp browsers... if (window.web3 !== undefined) { const provider = new Web3.providers.HttpProvider(window.web3.currentProvider); const web3 = new Web3(provider); } // Modern dapp browsers... if (window.ethereum !== undefined) { const provider = new Web3.providers.HttpProvider(window.ethereum); const ...


0

Check last transaction: https://ropsten.etherscan.io/tx/0xd45d32f88b6f8fc88c1a5984bf9d85aea50d6e50df0c22f461e39557d1296b6c # Name Type Data 0 _addresses address[] b3f17500e86c3cce3ecb47aba1073c4ffa940ec5 1 _amounts uint256[] 500000000000000 You try send ETH to another contract 0xb3f17500E86c3Cce3Ecb47ABa1073c4FFA940eC5which ...


1

Use accountsChanged event: /** * Listening for MetaMask address changes. * @param {Function} callback Resolve when address is changed */ function onAccountsChanged(callback) { ethereum.on('accountsChanged', (accounts) => { // Time to reload your interface with accounts[0] console.log(accounts); callback(null, ...


Top 50 recent answers are included