New answers tagged

0

I solved this issue with @monkrus 's answer by deleting the abi (or .json ) files redeploying the contract


0

ipfs.add(fileUploaded) works for me. buffer is not required. We can load the file directly. I am using "ipfs-http-client": "^50.1.2" and ipfs = create({ host: "ipfs.infura.io", port: 5001, protocol: "https" });


0

I built a simple tool that does this, called evm-fp. Here's how you could use it to format 500 USDT: import { BigNumber } from "@ethersproject/bignumber"; import fp from "evm-fp"; const decimals: number = 6; const amount: BigNumber = fp("500", decimals); The evm stands for Ethereum Virtual Machine, while fp for "fixed-...


2

In testB, a string is the argument of keccak256 while in testA, a hexadecimal literal is the argument. There are two solutions: 1- As @Kaki Master Of Time mentioned, you can remove quotes ("") 2- Replace by hex"0000....0002000....0000" Maybe the following codes make the concept more clear: bytes2 a1 = "12"; // fine bytes2 a2 = &...


0

I had a similar error. I solved it by changing the IP address I had been trying to connect to. from "https://10.161.162.12:8545" to "http://10.161.162.12:8554"


2

The issue is how you are passing the result of abi.encodePacked to the keccak256 function. keccak256 takes a hex argument and not a string as you did in your testB(). using an online tool i was able to get the correct result by passing a hex input type without the 0x at the start of the input. for your case here passing just the hex directly without the ...


0

I don't think it's possible.But it can go like this: This can be resolved by having the user approve approval(yourAddress,max_uint) for the first time for your account to use one of its tokens, and when a third party wants to use it, it will also be through you. It's a viable solution, but I'm not sure it will meet your needs;


0

Like Shahid said, it has to do with an issue with 2.0.0 of ethereumjs-tx Note that the hardfork property is optional.


0

Try to print the value of web3.eth.accounts.wallet. I think this is giving an undefined value. console.log(web3.eth.accounts.wallet) See if it is giving a wallet address or not. In some cases, it is not able to fetch accounts.


0

gasLimit is the number of units of gas used by the transaction, not the actual value of that gas. what your code is trying to do is to create a transaction with a gas cost of 10 gwei (0,00000001 ether)/gas unit, using 0.5*10^18 gas units. Effectively resulting in the transaction costing you 0.00000001 x 0.5 x 10^18 = 5 billion ETH (maybe thats a bit ...


1

The error call revert exception means that: Method reverts during its execution. Method is not present in your contract. Contract not deployed on the network you're connected to (or address put is incorrect). Your network has some temporary outages. The third one is a frequent dev error, and it's likely also the reason for you.


0

Gas cost of a transaction = gas consumed * gas price In a normal eth transfer, gas consumed is 21000. So now you have to set the gas price such that the multiplication is 0.5 ETH. var tx = { to: "0x73E7D230586B118898aA1FB95FAA6E4119FA0996", value: ethers.utils.parseEther("0.01"), gasPrice: ethers.utils.parseEther('0.5').div(21000), ...


0

There are two things here. First, the error you get call revert exception when: Method reverts during its execution. Method is not present in your contract. Contract not deployed on the network you're connected to (or address put is incorrect). Probably you're facing the 3rd issue. Second, ethers.js has a different API for .call() and .send(). If your ...


0

You are not installing from the official repo. From the image you are installing npm install etherium/web3.js (there's a typo etherium). The web3 project started from Ethereum organization, but it is now being developed by ChainSafe. The official readme indicates npm install web3 for installing. npm install web3


0

When you copy-paste Git URL, use https:// instead of ssh:// Or, alternative, add SSH key to your SSH agent, probably using command ssh-add. This really depends on course instructions and this question should be addressed to whoever is running the course, not a public forum.


0

For those who are still looking for an easy answer: let accounts = await web3.eth.getAccounts() will assign whole array to accounts. Then you can access as accounts[0] to the first one


0

This was due to the contract not having enough funds to carry out a function that I asked it to carry out .


0

You should do like that: this.myContract.methods.addData(declaration, { from: '0x3b0282D31174B927e102bA71d80dF34F4e596Fc4', gas: 12000 }).send() ;)


0

You can refer the below for signing data from metamask, https://docs.metamask.io/guide/signing-data.html#signing-data-with-metamask https://github.com/danfinlay/js-eth-personal-sign-examples


0

My guess would be that you're using that same wallet somewhere else. Web3 keeps an internal note of the nonce, and it internally increments it once it makes more transactions via the Web3 script. If you use that same wallet somewhere else (i.e., another Web3 script or in Metamask), that internal nonce would go out of sync with the real nonce that is needed ...


0

If you want to encode 1234 to a bytes array from web3 you can combine toHex and padLeft from web3.utils. > web3.utils.padLeft(web3.utils.toHex(1234), 64) 0x00000000000000000000000000000000000000000000000000000000000004d2 To decode from solidity call sliceUint with start = 0 bytes memory a = hex"...


1

I guess this will work fine: pragma solidity >=0.4.16 <0.9.0; contract Convertion { function test(bytes32 _input) external pure returns (address) { return address(uint160(uint256(_input))); } } Refer Solidity doc: If you convert a type that uses a larger byte size to an address, for example bytes32, then the address is truncated. To ...


1

Web3.py doesn't offer methods to subscribe automatically so we have to manually listen to the websocket and use rpc methods to send the subscription to logs : import asyncio import json from web3 import Web3 from web3.middleware import geth_poa_middleware import requests from websockets import connect from eth_abi import decode_single, decode_abi adapter = ...


1

Minor blockchain reorganisations up to 6 blocks deep are normal for Ethereum. Ethereum mainnet with proof of work has only probabilistic finality, not true finality and any block is subject to disappearing. More about finality here.


0

I found this issue only on infura api. So i switched to my own RPC node and now i haven't seen this issue again.


0

web3.py doesn't have a native implementation of watchers like web3.js. your only option is to connect to the exposed websocket like follows: import asyncio import json import requests from websockets import connect async def get_event(): async with connect("ws://localhost:8545") as ws: await ws.send({"id": 1, "method&...


2

ERC721Enumerable inherits ERC721 and ERC721 inherits ERC165. So this below article may help you. https://medium.com/@chiqing/ethereum-standard-erc165-explained-63b54ca0d273 Let me know if this works for you. If not then will look for some other solution.


0

Fixed, answer is use padding example -> 0x0000000000000000000000000D81d9E21BD7C5bB095535624DcB0759E64B3899 Sometimes the simplest answers are right infront of you


0

This is straight from the documentation: web3.eth.sendTransaction({from: '0x123...', data: '0x432...'}) .once('sending', function(payload){ ... }) .once('sent', function(payload){ ... }) .once('transactionHash', function(hash){ ... }) .once('receipt', function(receipt){ ... }) .on('confirmation', function(confNumber, receipt, latestBlockHash){ ... }) .on('...


1

From the trace of the transaction you can see it calls CALLVALUE before calling REVERT. [46] 1235 CALLVALUE 777090 2 1 [47] 1236 DUP1 777088 3 1 [48] 1237 ISZERO 777085 3 1 [49] 1238 PUSH2 777082 3 1 [50] 1241 JUMPI 777079 10 1 [51] 1242 PUSH1 777069 3 1 [52] 1244 DUP1 ...


0

You can find the example of how to do it in Solidity docs: https://docs.soliditylang.org/en/v0.8.6/solidity-by-example.html#micropayment-channel


0

Find the below example, const release = async () => { try { //Set price to 1 Gwei let gasPriceHex = ethers.utils.hexlify(8000000000); //Set max gas limit to 4M var gasLimitHex = ethers.utils.hexlify(4000000); // Raw Transaction var rawTx = { gasLimit: gasLimitHex, gasPrice: ...


0

a way is iterating over contract for (var i = 0; i < contract.abi.length; i++) { if (contract.abi[i]["type"] === "function" && contract.abi[i]["stateMutability"] === "view") { console.log("read-only function:", contract.abi[i]["name"]) } }


2

You should have your ABI in JSON format (list or dictionary), not as string


1

You need await your own async functions const s = await supply()


0

Turns out that this can be easily done by import type Contract from the source code of web3.


1

myContract.methods.methodName().call(transactionObject, blockNumber, callback) No, it is not the way to do it. The block number in RPC methods is meant for historic purposes only, not to execute functions in the future. What you need to do is to monitor the network, and when the block_number-1 will be announced, send your transaction expecting that on the ...


0

Issue was in the custom compile script / ABI. Used the truffle lib to compile and deploy the contract. The issue was gone.


0

I use this contract: // SPDX-License-Identifier: MIT pragma solidity >=0.4.21 <0.9.0; import '@openzeppelin-contracts/contracts/token/ERC721/ERC721.sol'; import '@openzeppelin-contracts/contracts/finance/PaymentSplitter.sol'; contract BALANCE is ERC721 { event NftBought(address _seller, address _buyer, uint256 _price); mapping (uint256 => ...


1

insufficient input amount means the router contract didn't receive the expected amount of your inbound token (WETH) do you have enough eth in your calling address to support the call?


1

Another way is to use promise instead of call back: web3.eth.getBalance(address).then(result => web3.utils.fromWei(result,"ether"))


0

You are returning uint on your contract but your abi says it is array I'm not sure but you should check your abi. I couldn't add comment because of reputation.


0

just change to value="0x00" so it is an even length byte


0

I couldn't know for sure if you only want to know the web3.eth.Contract type. But if it's what I imagine you can use this: import { Contract } from 'web3-eth-contract'; For example: import { Contract } from 'web3-eth-contract'; import { AbiItem } from 'web3-utils'; const Contract = new web3.eth.Contract(Token.abi as AbiItem, address)


1

I end up solving this error by changing the version of web3, I was in version 0.20.x, and I changed it to the latest version, which was 1.4.0.


0

I recommend you using Moralis. It has SDK for React with cool hooks. It also supports different providers (walletconnect, metamask, ...). Take a look at Moralis React Github. It has own speedy nodes for BSC, ETH and Matic networks. Example of getting user wallet address: import React from "react"; import { useMoralis } from "react-moralis"...


2

For Moralis to work properly, you have to host your pages through a server. When you open the HTML file directly, you will face this issue. This has been mentioned in the moralis docs for your reference over here - Uncaught Reference error- Non Ethereum Browser Hope this helps.


1

Yes, it's possible to have several instances of web3 inside your dApp, but it only makes sense if you want to sign transactions or read data on multiple chains. I don't see any reason why you would want to include multiple providers which are pointing to the same chain.


0

Your code is not formatted when pasted here, but I created the following sample which will help you to read struct from another contract. This is the contract which is holding the struct data: pragma solidity >=0.7.0 <0.9.0; contract Test { struct studuim { string name; uint256 id; } studuim [] public studuims; ...


0

So, after some days I got back to it, and managed to solve it. The problem was that the contract I had deployed did not have any data in it. So, the storeproducts had a length of zero (nothing on it), so I belive that is the reason why it did not work Second thing that might have done is I got a newer version of Nextjs and Web3 Also recreated the whole ...


Top 50 recent answers are included