Hot answers tagged

3

You're right, the contract can't call itself the "approve" method. Instead you can write a script. An exemple with web3js 1.2 could be : var erc20Instance = new web3.eth.Contract(abi,Token_address); erc20Instance.methods.approve(contractAddress, amount).send({from: userAddress}, function(err, transactionHash) { //some code }); with : abi : the abi of ...


2

Does returning false prevent bool function from further execution in Solidity? Returning any value prevents any function in (probably) every language from further execution. This will give bad jump dest or revert, correct? No, not correct: revert and require(<an expression which evaluates to false>) will revert the transaction with a REVERT ...


1

The approve function is used to set allowance for the current sender. If you would call it from your own contract, you would approve spending the tokens for your own contract. Instead of calling approve through a smart contract, you have to send the transaction directly from the user to the ERC-20 contract, with the address of your own smart contract ...


1

Your on, once and then are wrong. Please try as below: this.state.token.methods.approve(this.state.neutralG.address, qty).send({ from: this.state.account}) .on('receipt', (receipt)=>{ this.callCreateEscrow(); console.log('receipt'); }) function callCreateEscrow(){ this.state.neutralG.methods.createEscrow(intvalue, 3600, price, this.symbol, ...


1

You may create multiple contracts to interact with erc20 token so as to virtualize the interaction & increase the abstraction. As you create multiple contracts, you may choose only to make calls to initiate the processes that is paid by another contract. Also you can create a private network where miners only work for you.


1

Each token has exactly one token contract which acts as the token ledger. A token contract is typically for just keeping track of that one token - who owns and how many of said token. A token contract typically cannot manage other tokens. In theory you can add such functionality into one but it would not be a very good idea. If you want to have some way to ...


1

Given that you are using infura, you need to work with functions that use local private keys in web3py. See here for details To sign a transaction locally you should use w3.eth.account.sign_transaction(transaction, key) your code will then be like this: def send(web3, private_key, gas_price, transactionABI, value=0): tx = { 'to': units_address, ...


1

A BigNumber is an immutable object which allow accurate math operations on values larger than JavaScript can accurately handle. In order to deal with it in ethers.js, we have a library under utils, which is the BigNumber library. ethers.js/Big Numbers Example > let gasPriceWei = utils.bigNumberify("20902747399") > gasPriceWei BigNumber { _hex: '...


1

Yes, you can do it. You can create a Mintable / Burnable ERC-20 (Standard Fungible Token), and you can reward users by minting Tokens into their wallets. Users must first have an Ethereum Wallet. You can have a look to Open-Zeppelin to easily deploy an erc20.


1

In contract DemoContract is ERC20,ERC20Detailed,ERC20Burnable,ERC20Mintable, ERC20Pausable: Each one of contracts ERC20Detailed, ERC20Burnable, ERC20Mintable and ERC20Pausable already inherits from contract ERC20, so you should not inherit from this contract as well. For example, compiling the following code gives the same error as yours: pragma solidity ...


1

You can do something like this: const fs = require("fs"); const Web3 = require("web3"); const NODE_ADDRESS = process.argv[2]; const PRIVATE_KEY = process.argv[3]; const CONTRACT_NAME = process.argv[4]; const ARTIFACTS_DIR = __dirname + "<path to your bin/abi folder relative to this script>"; const MIN_GAS_LIMIT = 100000; // increase this if ...


1

The gas required exceeds allowance (8000029) or always failing transaction error consists of two parts, either one of which may have taken place: The gas required for executing the transaction exceeds the gas-limit for the given block The transaction has reverted due to require(cond) with cond evaluating to false From my experience, this error is issued ...


1

The ERC20 token standard does not include update method (minting) for totalSupply unless you have built it before deploying. If you didn't do that and your contract is already deployed you have no other choice, but redeploying your contract.


1

Please check this tool. You need to make your javascript browser compatible to use require() features.


1

A reason for wallets to not notice new tokens being minted is that they will only listen for Transfer event. In the ERC20 specification only Transfer event is defined. For example OpenZeppelin's implementation generates a Transfer with sender being the null address 0x00000000...00. emit Transfer(address(0), account, amount);


1

Here is the Transfer event prototype on each standard: ERC20: event Transfer(address, address indexed _to, uint256 _value) ERC721: event Transfer(address, address indexed _to, uint256 indexed _tokenId) These two signatures are indeed the same when you hash them for the purpose of locating Transfer events in the ledger using (for example): receipt.topics[0]...


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