New answers tagged

0

You can see more information here. Basically you should send the recipient and the amount: await expect(() => wallet.sendTransaction({to: walletTo.address, value: 200})) .to.changeEtherBalance(walletTo, 200);


0

web3 works a bit different than ether.js so when you deal with web3 you first establish a connection with the dapp and than when you call a function which change the state you use send() and pass from field with it. // Do connect to the metamask and bring the account address. Example: const web3 = new Web3(window.ethereum); const contract = web3.eth.Contract(...


0

Make sure the mnemonic variable in truffle.js file matches the one from your local blockchain, Ganache.


0

The function withdraw fails because this call returns false indicating the transfer failed msg.sender.call{value: _withdrawAmount}(""); It fails because the contract doesn't have enough ether. The script isn't sending ether with addBalance(5) it just increases the internal balances mapping. To send ether with the call have to write something like ...


0

I faced the same problem. I didn't know I had to install ethers besides hardhat-ethers. So I installed ethers by running the following command: npm install --save-dev ethers And added the following line to the top of the test file: const { ethers } = require("hardhat"); It works well now.


0

In my case, I got that exact error message because I instantiated a contract using an incorrect address. Fixing the address made the message go away.


0

I faced with the same issue. I was on a testnet and got this while I had enough test ethers for the gas fee. So the point is this message is ethers.js related and this Github comment helped me to understand the situation. In a nutshell, this error message is not because you have insufficient funds, it can be a sign of a different issue. In my case it was a ...


1

ethers also has a padding function where it will add the zeros to make it the correct length. It looks like this const oracleResponse = ethers.utils.hexZeroPad(ethers.utils.hexlify(1), 32) This will pad your result to be length 32, and allow it to be accepted by your function.


1

There is, indeed, a faster way : use 2 different contract interaction type, one static call (to get the returned value, will not mine the transaction) and one regular transaction (as you were doing, but you can then discard the wait() result) : const address_of_sub = await mainContract.callstatic.mintSubContract(500); //no state change/no gas await ...


0

I don't think it's possible, because with first call you are asking a ERC20 contract to allow your contract to spend funds and only after successful transaction you can call TransferFrom from your contract.


0

You would use the to, data, value, gasPrice and gas fields to construct an Ethers transaction, sign it and send it. Most javascript frameworks allow passing in the entire response and it will pluck out the needed values. I would consult the Ethers.js documentation for more info and examples.


0

Rather listen for the ordersMatched event, which include a price param (see the 3d log event: https://etherscan.io/tx/0x49a1b9af049ff10cc8e61ad49499c3615b1455a33c9cda6cc0390142d0058281#eventlog or the actual event in wyvernEngine : https://etherscan.io/address/0x7be8076f4ea4a4ad08075c2508e481d6c946d12b#code line450).


1

Currently there is not. You have to xor all function selectors of IMyContract. To make your life easier, you can use ethers.js interface and use its getSighash functions to not have to hash it and slice it ourself. But still you have to xor these selectors to get an interfaceId.


1

You can set the params in the transaction object itself. In the given example. contract = new ethers.Contract(addr, abi, provider); withSigner = contract.connect(signer); await withSigner.runFunc(param1, param2, { maxFeePerGas: "<YOUR GAS FEE>", maxPriorityFeePerGas: "<YOUR PRIORITY FEE>" }); In the above code, you ...


1

This took a fair amount of playing around, but finally discovered that: await NFT.connect(sender)['safeTransferFrom(address,address,uint256)']( sender.address, recipient.address, ethers.BigNumber.from("1") ); is the winning combination. Don't put a . after connect(sender).


Top 50 recent answers are included