Hot answers tagged

4

1) Matching the ERC777TokensRecipient interface is optional. More specifically, one single ERC1820 registry is deployed on most Ethereum networks, always at the same address: 0x1820a4B7618BdE71Dce8cdc73aAB6C95905faD24. The ERC1820 registry contains a mapping from addresses to contract addresses verifying the ERC777TokensRecipient interface. Those ...


4

Etherscan will recognize your contract once it will log its first Transfer event. This is how it works. Though, even before the first Transfer event was logged, you may view your contract in token tracker: https://rinkeby.etherscan.io/tokens?q=0x5238fFeAEdfc9481bd635B6E0e5eF3b05b19762a


4

The output you receive is in hex format. You need to conver hex to an int. Here is the full code you need to use: const contractInstance = web3.eth.contract(contractAbi).at(contractAddress); const total_supply = parseInt(contractInstance.totalSupply.getData()); console.log(total_supply); I added parseInt() to convert your hex number into a human readable ...


4

In your case, you must implement smart contracts on top of your ERC-20. What you're doing is more like a Security Token; in this case, you can use different standards such as: ERC-1400 or ERC-1404 (Polymath) T-REX (Tokeny) ERC-1404 is another standard for security tokens, supposed to be more 'user-friendly', Know Your Token Holders: "Know who your ...


3

This sounds like a perfect use case for the now finalized ERC-1155 token standard, which allows one to manage any number of fungible and non fungible tokens in a single contract.


3

If you arrived here looking for a way to print the events emitted during your tests, you can do this with the --show-events flag: truffle test --show-events


3

On web3.js v1.x, you should fix the following: Change web3.eth.Contract to new web3.eth.Contract Change omisegoContract.balanceOf to await omisegoContract.methods.balanceOf Of course, the 2nd bullet implies that this line should be executed from an async function.


3

Just don't use BN. You need to convert ETH to WEI. This is a very simple proccess. Web3 has some buildt in functions for this: const val = 0.15; // this guy var weiAmount = web3.toWei(val);


3

There's no way for you to get them back, tokens sent to that particular contract that you're referring to, are stuck there forever. The contract that you link to has no way to withdraw tokens mistakenly sent to it. Perhaps your best chance is to reach out to the MWAT team and explain your situation, perhaps they can try to resolve it in someway.


3

Decentralized Finance (DeFi) is the movement that leverages decentralized networks to transform old financial products into trustless and transparent protocols that run without intermediaries. Some may prefer to call DeFi as Open Finance, Distributed Finance, or EthFi(referring to the fact that at the moment most of existing DeFi products built on Ethereum....


3

An ERC20 contract must exactly implement the specification described here: https://eips.ethereum.org/EIPS/eip-20. This makes the critical behavior predictable so it will be compatible with wallets and exchanges. A contract may implement additional behaviour provided it doesn't interfere with the minimum functionality. It's worth noting that exchanges and ...


3

To send ethers is very simple: // Submit transfer operation const receipt = await multisig.submitTransaction(recipient, amount, "").send(); // Obtain transactId from receipt const transactionId = ...; // When confirmed by owners majority it will execute To send ERC20 is slightly more complicated // Encode ERC20 transfer operation const data = token....


2

Here's json result from your api call: { jsonrpc: "2.0", id: 1, result: { blockHash: "0x8fe66b0c15a1c1155338bb5628db55f05cfe72d1194931134b4721cd07e9eda7", blockNumber: "0x416850", from: "0x167a9333bf582556f35bd4d16a7e80e191aa6476", gas: "0x13880", gasPrice: "0x4e3b29200", hash: "...


2

Most use-cases can be solved by inverting control. Rather than having the contract run something at a certain time, interested parties claim entitlements when appropriate. The contract decides if the requests are permissible. So, a delayed entitlement would go: Buyers sends ETH. Contract records future entitlement to tokens. When (not before) and how much....


2

You can check with the code below that this line: uint256 roundValue = SafeMath.ceil(_value, basePercent); If your value _value is higher than basePercent, roundValue will be the number rounded on the hundred, otherwise the _value will be basePercent always. Example: input = 1--> roundValue = 100 Example: input = 4111--> roundValue = 4200 Code: ...


2

Because Solidity only supports integer numbers, there's no natural way to represent a value like "half a token" (0.5 tokens). To work around this, ERC20 tokens use a multiplier. For US dollars, you might use a multiplier of 100, or 10^2, for 2 decimal places. In code, you'd store the number of pennies rather than the number of dollars. So $1 becomes 100 ...


2

I voted for Jesse's answer. For the benefit of others who come across this, a little example of the last option mentioned: contract A { function someMethod(address sender) public{ // Something happens here // proceed using "sender" the msg.sender says the transaction is for. } } contract B { A instance = new A(); ...


2

When a contract B is calling another contract A, msg.sender in contract A will always be B. There is no way around that. You haven't given a lot of information. Depending on the rest of your code, here are some things to consider: Move someMethod() to contract B Call someMethod() directly, instead of through wrapper_someMethod() Use tx.origin in contract ...


2

The EVM bytecode (compiled form) is available/observable to all users at all times. The data in contract states, including variables explicitly marked private, is available/observable to all users at all times. private describes visibility to other contracts but it is a misunderstanding to assume it implies protection for confidential information. ...


2

You misunderstood the flow. You have User => Escrow.deposit() 1. Escrow => token.approve(this, amount) 2. Escrow => token.transferFrom(msg.sender, amount); // msg.sender did not approve this That won't work for the same reason I (for example) can't approve myself to withdraw your funds and then do it. It has to go: User => token....


2

The target contract is a non standard ERC20 token. It should have three topics, two indexed parameters and the event id and the transfer value in the data field. But it has four topics instead. "topics": [ "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef", "0x000000000000000000000000c5ec6937d3278311e2ace517df214717310c0820", "...


2

pragma solidity ^0.5.0; //import ERC20 functionality ... contract Example { ERC20 public token; //@param _token the address of the DAI smart contract constructor(ERC20 _token) public { token = ERC20(_token); } function () external payable {} ...


2

You need to send the tokens at least once first. Otherwise this will not work. Etherscan only recognises a contract as an token after its first Transfer event. After sending the tokens once it should work perfectly!


2

In web3.js v0.x: The expression contractInstance.totalSupply.getData() would get you the encoded ABI data (byte-code) of a call to function totalSupply. In order to actually call the function and retrieve the return-value asynchronously, you should use: contractInstance.totalSupply.call().then(total_supply => { console.log(total_supply); }); In ...


2

This topic is kindof interesting. There are a few things you can do: Report the token on etherscan: In my opinion this is probably the most effective thing you can do. Go to etherscan.io/dapp/0xScamTokenAddress On the bottom of the left sidebar you will find a "Report Button". Write a blog post: If you don't have a blog this solution is probably not the ...


2

Simply put, the answer is no - there is no standard way to do this, as how tokens are created isn't defined in ERC20. Additionally, you can't easily find out the holders of tokens directly from the blockchain, as the way storage data is encoded means that, even if you're looking at the raw data, you'll only be seeing the hashes of the token holder's ...


2

It is unclear what layer you want to find out this information on (on-chain or off-chain). In general: Is an address a smart contract? This can be checked by seeing if there is associated code at the address. Is this smart contract ERC20 or ERC721 token? Off-chain, you can check this by observing the contract on Etherscan. There are also interfaces ...


2

For 1 you may use web3.eth.getCode(address) function of Web3 API. For contract addresses it returns contract byte code, while for non-contract addresses it returns something like "0x". For 3 it depends on what "public" means for you. If you mean whether smart contract has verified source code published at Etherscan.io, then you may use either API call to ...


2

You should be aware that smart contracts on ethereum cannot interact directly with the outside world. So you will never have a token that reflect instantly the price of real world goods. It is possible however to use oracles to keep the price reasonably updated. This can be done through a centralized authority or decentralized one. For example DAI and USC ...


2

The ERC20 specification states that they should be public instead of external. It does violate the ERC20 specification if you mark them as external. However, in practice this should not be an issue. The difference between external and public functions are that in public functions, the call data is copied to memory first. In external functions, the data is ...


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