New answers tagged

0

I think this is better handle with better contract design. Instead of handling buy/sell transaction variables one-by-one, you can have a struct defining an escrow transaction. Something like: struct escrowTx { uint256 TransactionID; address Seller; address Buyer; bool Executed; ... } Then each escrow transaction is just a new instance of this ...


0

When a function is executed off-chain msg.sender could be anything. Since no changes is persisted on the blockchain the execution is just a simulation. If a view function is executed on-chain as part of a transaction then msg.sender is always a valid address.


0

While the return value of a function call executed on-chain cannot be returned off-chain, you can however simulate a function call on-chain to see what that function call would return. In ethers, you can use callStatic. From ethers' documentation: Rather than executing the state-change of a transaction, it is possible to ask a node to pretend that a call is ...


1

The formula in your question describes a gas cost for the total amount of memory allocated in a contract call (i.e. the biggest memory location that contains a nonzero value. Zeroing memory after using it does not decrease the total amount of allocated memory). Note this is in addition to the base 3 gas of an mstore opcode. In the above formula, a is the ...


0

Let's figure this out empirically with ethers.js: const input = { foo: BigNumber.from("3"), bar: BigNumber.from("1") }; const data: string = targetEcho.interface.encodeFunctionData("echoStruct", [input]); const response = await proxy.callStatic.execute(target, data); console.log({ input, response }); That produces the following ...


1

The values maxPriorityFeePerGas, maxFeePerGas and value should be in Wei (the smallest unit on Ethereum). You can use Ethers.js' parseUnits to convert a value in Gwei or Ether to Wei: contract.someMethod(someArgument, { gasLimit: 100000, maxPriorityFeePerGas: ethers.utils.parseUnits('5', 'gwei'), maxFeePerGas: ethers.utils.parseUnits('200', 'gwei'), ...


1

You can fork Rinkeby or the Mainnet pretty easily using Ganache-CLI. Read this article for a detailed explanation https://blockheroes.dev/test-smart-contracts-on-mainnet/ The simplest command is: ganache-cli --fork https://eth-rinkeby.alchemyapi.io/v2/{myKey} But you can personalize it by specifying: the block number from where you want to fork an address ...


1

The process for manually adding a contract address for ERC20 (ETH) tokens will depend on your particular wallet. If using Metamask, you can select "Assets" tab, scroll all the way to the bottom and click "Add Token". Select "Custom Token" and there you are able to input the token contract address and symbol. After clicking next, ...


3

Declaring a function as external rather than public does not affect gas usage at all, neither in contracts nor in libraries. In earlier versions of Solidity only external functions could take calldata arguments. Making a function public would force you to use the more expensive memory arguments. This restriction was lifted in Solidity 0.6.9. This is probably ...


0

In addition constant (view or pure) functions only cost gas if the constant (view or pure) function is executed or called by another external smart contract, that is not the owner of that function. But if it is called from within the smart contract that declared the constant (view or pure) function, then no gas will be used. Just like when you use a class ...


0

First of all let's look what "public" means. Public, functions can call internally or externally. Internal calls is a basic jumps on EVM. So they takes more less gas than external calls. If you call public functions in your contract that is an internal call. In your situation you are calling your function by internally. If you change it to ...


0

Miroslav gave a good explanation. You can also check this out.


0

Let's start with this - ETH isn't a token, but a coin, because it's native to Ethereum blockchain. Tokens are logic built on top of already existing blockchain. Making blockchain movements in ethereum network can be paid only in ETH fees. But if what you're trying to do is not paying the fee with tokens, but actually sending tokens to a contract method then ...


Top 50 recent answers are included