Hot answers tagged

2

The original use case from back 2016 is that back in a day, smart contracts had no way to interact to incoming token transfer. (This has been now fixed with ERC-777 token standard and send()). For you to interact with a smart contract with an ERC-20 token You need to approve() amount of tokens on a smart contract address You call a smart function that then ...


2

To send tokens you call the transfer function of the contract. This is done by sending a transaction with a value of 0 ETH to the token contract, with transaction data containing the function identifier, address to send the tokens to and the number of tokens to send. This is done through your own wallet. Note that transfer and Transfer are two different ...


2

In order to execute a state-changing function within a transaction, you need to use send. On Truffle you can also omit it and let Truffle choose the default: call for constant functions (either pure or view) send for non-constant functions (neither pure nor view) So in short, you need to change this: await token.changeAdmin.call(newAdmin, {from : ...


1

and even though it increases the total supply, it is not logging the transfers on the ropsten token tracker First of all, the total supply does not increase during transfers by definition, because tokens are simply transferred from one account to another. No tokens are minted or burned, so there is no reason to change the total supply. There is nothing in ...


1

The native word size of Ethereum virtual machine is uint256. There is no really need to use smaller words, like u128 or u64 for accounting purposes, as there are no real gas efficiency gains. Thus, it is practical to use the uint256 EVM wise. Note that arguments are RLP packed when communicated to the EVM, so any leading zeroes do not increase the cost, as ...


1

“The price of a given token on a given exchange can be calculated as the exchange contract's token_balance divided by its ether_balance.” This description means: On-chain price: In opposed to off-chain price, which is what you may see on various exchanges, and which can of course be different on every exchange. Spot price: This is the rate that you will ...


1

A token-transfer transaction on the Ethereum blockchain: to : token contract address data : the encoded function call gas : the amount of units required to execute the transaction, or more gasPrice : the higher this value is, the faster you transaction will execute value : none (0) An ether-transfer transaction on the Ethereum blockchain: ...


1

Since InterfaceToken(token).invest is an external call (i.e., to a function in another contract), you need to pass along the value that your function has received. In other words, change this: InterfaceToken(token).invest(contributor); To this: InterfaceToken(token).invest.value(msg.value)(contributor);


1

The reason the compilation stopped working is because that way of performing a call was only made available in Solidity 0.6.2: Allow gas and value to be set in external function calls using c.f{gas: 10000, value: 4 ether}(). Prior to 0.6.2, you had to use c.gas(_gasLimit).value(_value)(_data); This change is simply an added feature and not a breaking ...


Only top voted, non community-wiki answers of a minimum length are eligible