Categories
Cryptocurrency Ethereum Mastering Development

why require() is checked after executing transfer()

From OpenZeppelin’s ERC721 contract: function _safeTransfer(address from, address to, uint256 tokenId, bytes memory _data) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } In the above code, what purpose does require(…) server after _transfer() as the token will be transferred anyways? I would like to details regarding […]

Categories
Cryptocurrency Ethereum Mastering Development

Transfer Failing in Solidity Smart Contract

I am calling the following function from a front-end on a Solidity smart contract, but it is failing on the second transfer. Shouldn’t this be working? function tokTransfer(address payable from, address to, uint256 tokenId, uint256 price, uint256 commission) payable external { (bool success, ) = from.call{value: price}(”); require(success, "Transfer failed."); (success, ) = address(this).call{value: commission}(”); […]

Categories
Cryptocurrency Ethereum Mastering Development

Transfer Ownership of an NFT, as well as the Price and Commission in a Single Transaction

I am developing a dapp which will be used as a market where users can buy and sell NFTs from each other. From the dapp front-end, users will be calling the setApprovalForAll ERC721 function, granting my contract authorisation to sell their NFT tokens. Upon purchasing a token, the purchaser calls the tokTransfer function in my […]

Categories
Cryptocurrency Ethereum Mastering Development

`.at()` function no longer available for web3.eth.Contract?

I’m following a guide that uses some web3 code written 3 years ago. I am trying to use the TimeLockedWallet.info() call to get information about a wallet. Below are my two smart contracts. TimeLockedWalletFactory.sol pragma solidity ^0.4.18; import "./TimeLockedWallet.sol"; contract TimeLockedWalletFactory { mapping(address => address[]) wallets; function getWallets(address _user) public view returns(address[]) { return wallets[_user]; […]

Categories
Cryptocurrency Ethereum Mastering Development

NFT Token Ownership Transfer Initiation

I am developing a dapp/smart contract, where users will be able to sell/buy NFTs from each other (market). Users grant authority to the smart contract to sell any of their items on their behalf using the setApprovalForAll openzeppelin function. Once this authority granted, users can put their items on sale. I am having difficulty understanding […]

Categories
Cryptocurrency Ethereum Mastering Development

NFT Token Ownership Transfer Initiation

I am developing a dapp/smart contract, where users will be able to sell/buy NFTs from each other (market). Users grant authority to the smart contract to sell any of their items on their behalf using the setApprovalForAll openzeppelin function. Once this authority granted, users can put their items on sale. I am having difficulty understanding […]

Categories
Cryptocurrency Ethereum Mastering Development

NFT Token Ownership Transfer Initiation

I am developing a dapp/smart contract, where users will be able to sell/buy NFTs from each other (market). Users grant authority to the smart contract to sell any of their items on their behalf using the setApprovalForAll openzeppelin function. Once this authority granted, users can put their items on sale. I am having difficulty understanding […]

Categories
Cryptocurrency Ethereum Mastering Development

add liquidity to uniswap pool with Web3

Hi I am trying to add a liquidity to Uniswap on the Ropsten network using Web3 My javascript code is as follows: (async () => { console.log("account: ", this.state.account); const deployedContract = await new web3.eth.Contract( UniswapRouter02Contract.abi, "0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D" ); console.log(web3.currentProvider); console.log("pair address ", this.state.pairAddress); console.log(this.state); const liq = await deployedContract.methods .addLiquidity( this.state.firstAddress, this.state.secondAddress, 1000, 1000, 0, […]

Categories
Cryptocurrency Ethereum Mastering Development

Is this transaction fee for contract creation normal?

I am creating erc20 token. Transaction fee for it is about 0.3ETH. Contract size is not big. Is this price normal or am I doing something wrong? Gwei 262. Current Eth price 1917USD. Contract : pragma solidity ^0.4.24; import "./IERC20.sol"; import "./SafeMath.sol"; /** * @title NGEL token * * @dev Implementation of the basic standard […]

Categories
Cryptocurrency Ethereum Mastering Development

What is this allowance check in ERC20 transferFrom implementation

There is something i do not understand in this file: https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/UniswapV2ERC20.sol function transferFrom(address from, address to, uint value) external returns (bool) { if (allowance[from][msg.sender] != uint(-1)) { allowance[from][msg.sender] = allowance[from][msg.sender].sub(value); } _transfer(from, to, value); return true; } What is the goal of the first condition: if (allowance[from][msg.sender] != uint(-1)) I did not see this condition […]