Hot answers tagged

2

There are several checks performed. Let me explain them one by one: if (frozen) return false; If all transfers are frozen now, just return false. if ((addressFlags [_from] | addressFlags [_to]) & BLACK_LIST_FLAG == BLACK_LIST_FLAG) return false; If either _from or _to is in black list, return false. _value <= allowances [_from][msg.sender] &...


2

The allowances variable (table) is the one controlling who can transfer from who and how much. This variable can be configured via function approve. For example, if you sign the transaction erc20Token.approve(myAccount, 100) with your private key and then send it to the blockchain, then the value of allowances[yourAccount][myAccount] in the erc20Token ...


1

The statement escrow.originatorAddress.transfer(amount) can revert for either one of the following reasons: address(this).balance < amount escrow.originatorAddress is the address of a contract without a payable fallback function escrow.originatorAddress is the address of a contract with a payable fallback function which reverts when you execute the ...


1

Since the resolution of ether is 18 decimals, but the resolution of an ERC20-token is not necessarily the same, you can use this: uint256 amount; uint8 decimals = ERC20Interface(token).decimals; if (decimals > 18) amount = _quantity * _tokenPrice / 10 ** (decimals - 18); else amount = _quantity * _tokenPrice * 10 ** (18 - decimals); Be sure to ...


1

Slightly different to what you asked... (in that in the below we're querying an ERC-20 token contract to see if it contains a balance for a specific address). The following API will allow you to query an ERC-20 token contract (at a given address) for the balance associated with a particular account address. From https://etherscan.io/apis#tokens: https://...


1

A @Chan-Ho says, there is a transferFrom() in the buy function, and you said you didn't approve() first, so that is the first problem. This looks like the Token contract - AGI: erc20 = TOKEN(address(0x8eb24319393716668d768dcec29356ae9cffe285)); You have to call the approve() function there to "authorize" the snet contract to pull some tokens from your ...


1

You could just deploy an ERC20 token with a name of Tether, then call the mint function to populate your wallet with tokens and pretend this is Tether for testing purposes. Here's an example: pragma solidity 0.5.7; pragma experimental ABIEncoderV2; import { ERC20 } from "openzeppelin-solidity/contracts/token/ERC20/ERC20.sol"; contract MockTether is ERC20 {...


1

This is not erc721 standard this is erc20 standard function. For the etherscan to recognise your contract as erc72 your contract interface must implement the erc721 contract standard: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md. I don't see your safeTransfer function or ApprovalForAll event. The etherscan recognises your contract as erc20 ...


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