New answers tagged

0

Let's take a look at this method: token.transferFrom(msg.sender, address(this), amount); What the contract does is transfer a quantity amount of WETH token from the caller of the function (msg.sender) to the contract (address(this)). Now let's see the transferFrom method. The causes of transaction failure are as follows : if (src != msg.sender &&...


2

There is no specific reason for this. Most tokens use 18 decimals in order to achieve a high level of precision and to mimic the precision of ETH. Some use 2 decimals to mimic a fiat currency. Some use 8 decimals to mimic Bitcoin. An odd number of decimals would work fine in all protocols that I know of today.


0

It depends on whether the contract supports such functionality. Some staking contracts have such functionality but mostly contracts don't support it. The contract has lots of strange code so I'm unable to tell you right now whether it's possible. In general the chances for such functionality to exist are very low.


0

without having any ETH Impossible; an account must own ETH in order to execute a transaction. The only thing that you can do is to transfer tokens (or ETH) back to the sender account at the end of the transaction, in order to compensate it for the initial payment.


1

It's not clear if you edited out important sections or if they are missing. Possibility 1 - the way you are testing Possibility 2 - msg.sender doesn't have 100 tokens to spend Possibility 3 - you haven't instantiated your token instance In the example, token has no address for a contract that is actually deployed, just an interface to a hypothetical ...


0

Is the library still maintained? I used eth-balance-checker with ethers 5.0.17 but getting invalid signer or provider error.


1

Blockchain doesn't care if there are hundreds of tokens with the same name and abbreviation. However, Nasdaq, in this case, is a crypto exchange and no exchange would list two tokens with the same name. So it is in the project's best interest to have a unique name that won't make confusion.


0

You can construct a snapshot of all addresses holding a specific token at a specific point in time, using the Transfer events emitted on that token's contract, starting from the moment it was deployed and up until the desired point in time. For example, in order to construct a snapshot of the KNC token at block #4270000, you can do: const Web3 = require(&...


0

I found this article for ETH transfer: https://goethereumbook.org/en/transfer-eth/ And this one for Token transfer : https://goethereumbook.org/en/transfer-tokens/ Also for PHP developers there is this package: https://github.com/kornrunner/php-ethereum-token


0

With toke.approve(msg.sender, i), you are approving msg.sender to transfer tokens from your contract. With toke.transferFrom(msg.sender, u, i), you are attempting to transfer tokens from msg.sender. Bottom line, you should execute approve(yourContractAddress, i) using the msg.sender account. Side note: you wouldn't want your code to work, because if it did, ...


1

In general, ERC20 token transaction is completely different than ETH transaction. If transaction occurs between two contracts, for a ETH transaction the receipt contract must have fallback function in its code. Also, the sender must have fallback function in its contract code. Whereas, an ERC20 token transaction does not need any fallback function neither in ...


0

As you know, all Erc20 tokens have same rules. So you can create your own ERC20 token. I have published an article to explain it in step by step tutorial. Here you are: https://athamidn.medium.com/step-by-step-get-erc20-test-token-faucet-on-ropsten-d20850375f2c


0

Because all Erc20 tokens have same rules, you can create your own ERC20 token. I have published an article to explain it in step by step tutorial. you can find it here: https://athamidn.medium.com/step-by-step-get-erc20-test-token-faucet-on-ropsten-d20850375f2c


1

That is a poorly worded comment. It should read: Create a table so that we can map the addresses of token owners to those who are allowed to utilize the said owner's tokens. This lets you whitelist someone else to use your tokens. For instance, you can allow me to spend 10 of your tokens. So, with .approve, you save in the mapping: you => me => 10 ...


1

I'm not sure where you found that example but there are multiple issues with it: It's old. That version of Solidity shouldn't be used in new projects anymore The comments in it do not make sense so just ignore them It has a bit of weird code Perhaps the best and most widely-used modern implementation is from OpenZeppelin at https://github.com/...


0

Contract IBLCToken inherits from contract ApproveAndCallFallBack: contract IBLCToken is ApproveAndCallFallBack ... Contract ApproveAndCallFallBack declares function receiveApproval: function receiveApproval(address from, uint256 tokens, address token, bytes data) public; So in order for contract IBLCToken to be deployable, it must implement function ...


1

Sure, but the flow is a little counter-intuitive and takes some getting used to. You can send ETH and/or data to a contract function. The data can instruct a contract function to seize a certain amount of a token from someone, usually the msg.sender (but not necessarily). Your contract would use the ERC20, transferFrom(<funder>, <amount>) ...


2

Think I found the answer actually: Call a smart contract payable function sending erc20 token User/me first needs to call the approve function in the LINK contract then my Remix contract can transfer tokens from msg.sender to itself itself using LINK's transferFrom function.


1

The concept of decimals is purely for user-friendliness - inside the blockchain there are no decimals. That's why it's optional. If there are no decimals then you simply display what the token amount inside the contract shows - things get easier than with decimals. So it behaves like decimals was 0. This concept is rather confusing for many people. You can ...


0

It won't be a EIP-20 compliant token. Some services that relies on events will not work, like block explorer or light wallets. From EIP-20 specification: transfer Transfers _value amount of tokens to address _to, and MUST fire the Transfer event. [..]


0

In each one of these functions, you can add the preliminary requirement: require(_remainingSwapCredit == 0 || _flow.remainingSwapCredit == 0, "RSC must be reset"); Then post publicly, that whenever users "approve", they must ensure that their RSC is reset. This will require them to execute two transactions whenever their RSC is not reset....


0

In theory your contract is ERC20 compatible because there is no way to enforce (or even check) whether a contract emits the required events every time. And in any case there is no standard method for finding out whether a contract is ERC20 compatible or not. Anyway, this is mostly a matter of how different third parties have implemented their ERC20 ...


0

For ERC-20: transferring to 0x0? - No, totalSupply shouldn't change upon transfer burning an amount already placed at 0x0 address? - Yes, totalSupply should decrease upon burn (though I'm not sure how exactly you are planning to trigger that to begin with) should 0x0 be allowed to have non-zero balance? - Yes For ERC-1155, I believe that all answers are ...


0

I was returning a result that i assumed was 0 by default. Changed the function to; function getNFTBalance(address _owner) public view returns (uint256){ return nft.balanceOf(_owner); } Getting the right balance now


0

//SPDX-License-Identifier: GPL-3.0-or-later // A simple smart wallet to be used for testing. // Based on code from https://github.com/argentlabs/argent-contracts/blob/develop/contracts/wallet/BaseWallet.sol pragma solidity ^0.7.1; contract TestSmartWallet { address payable owner; constructor(address payable _owner) payable { owner = _owner; ...


1

pragma solidity ^0.7.0; contract Wallet { address private owner; constructor () payable { owner = msg.sender; } receive () external payable { // Do nothing } function execute (address payable _to, uint _value, bytes memory _data) public payable returns (bytes memory) { require (msg.sender == owner); (bool success, bytes ...


0

You still need to supply the mixing smart contract the actual address to which you want to transfer the tokens to at some point. And since all (state-changing) transactions to smart contracts are publicly visible in the corresponding block, others could easily infer the sending and receiving parties.


0

The transaction is sent to the ERC20 contract, not to your contract. The ERC20 contract maintains a record of how many tokens are owned by your contract. As a result of the transfer, this record within the ERC20 contract is updated. Holding tokens is more like putting your money in a bank rather than keeping it in your wallet. That bank maintains a ledger ...


0

Yes, LOKI now available on UniswapProtocol Swap wLOKI <-> USDT : https://uniswap.info/pair/0xf00fe8deba4fe94642846a91568f43bd93333ffb Swap wLOKI <-> LOKI : https://wloki.chainflip.io https://loki.network/


1

You cannot transfer tokens from a contract address, unless that contract address has a function built-in to send a transaction or recover tokens in some way. It doesn't look like DAI has this built-in, so I'm afraid that your tokens are lost. In the future, double check the address you're sending to, and send a small test transaction if you're moving a ...


0

Since B inherits from A the deployed contract contains the methods from both A and B, so the same address can be used as both A and B When contracts A and B are deployed separately you have two addresses that are unrelated. For example you can deploy the same contract twice and obtain two completely independent addresses. If contract C imports B but it ...


1

You seem to be confusing between transaction and token-transfer, so I'll give you a short introduction of the technical terms that you need to understand IMO. Transactions There are 4 basic types of transactions: Transferring ether to an account Transferring ether to a contract Deploying a contract Executing a function of a contract #2 is essentially a ...


Top 50 recent answers are included