Experienced developer here, trying my hand at figuring out Ethereum development.
My problem is if I connect MetaMask to my local Ganache instance, I can't transfer my DOG token from one account to the other. I can transfer my test ETH, but when I try to transfer DOG it gives me this infamous error: VM Exception while processing transaction: revert
I made a contract as so: pragma solidity ^0.6.2; import "@openzeppelin/contracts/presets/ERC721PresetMinterPauserAutoId.sol"; contract DogCard is ERC721PresetMinterPauserAutoId { constructor() public ERC721PresetMinterPauserAutoId( "Dog Cards", "DOG", "https://dogcardcrypto.com/token/" ) {} }
It works fine using truffle tests. Here's a passing test: contract("DogCard", accounts => { it("Works?", async function() { const dog_card = await DogCard.deployed(); const [owner, sender, receiver, randomguy] = accounts; let contract = new web3.eth.Contract(dog_card.abi, dog_card.address); // Balance goes from 0 to 1 after minting token. assert.equal(await dog_card.balanceOf(receiver), 0); let coin = await dog_card.mint(receiver); assert.equal(await dog_card.balanceOf(receiver), 1); // Using web3, transfer new token. let tokenId = 0; transfer = await contract.methods.safeTransferFrom(receiver, randomguy, tokenId).send({ from: receiver, gas: 133520 }); // Verify the balances are correct. assert.equal(await dog_card.balanceOf(randomguy), 1); assert.equal(await dog_card.balanceOf(receiver), 0); }); });
As ambiguous as my issue is, does anyone know why I can't transfer the token in MetaMask? I have 100 ETH in the test account. It's not a gas issue as far as I can tell. I can mint a token to my test account and see it inside MetaMask after I add the contract address, but I get an error when attempting to transfer. What gives? Thank you. submitted by /u/plentyofhacks
[link] [comments]
http://dlvr.it/RxBkWC
0 Comments