Hi guys! I wrote a basic ERC721 contract with the code generator from OpenZeppelin. It works perfectly with all of its functions but the most i use are the safeMint and ownerOf ones.
I'm developing a frontend nodejs application so i'm using web3js.
leaving here the smart contract code
pragma solidity ^0.8.2;
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
contract CarbonFootprint is ERC721, ERC721Enumerable, Ownable {
using Counters for Counters.Counter;
Counters.Counter private _tokenIdCounter;
constructor() ERC721("CarbonFootprint", "CFP") {}
//la funzione seguente crea un nuovo NFT e aggiorna il contatore NFT
function safeMint(address to) public {
uint256 tokenId = _tokenIdCounter.current();
_tokenIdCounter.increment();
_safeMint(to, tokenId);
}
// The following functions are overrides required by Solidity.
function _beforeTokenTransfer(address from, address to, uint256 tokenId)
internal
override(ERC721, ERC721Enumerable)
{
super._beforeTokenTransfer(from, to, tokenId);
}
function supportsInterface(bytes4 interfaceId)
public
view
override(ERC721, ERC721Enumerable)
returns (bool)
{
return super.supportsInterface(interfaceId);
}
}
What i wanted to ask is: who generates the nft when the function safeMint is called? testing with remix i get this
"args": {
"0": "0x0000000000000000000000000000000000000000",
"1": "0xbD1d346577a444143E308BAbE1aa279e26e5f595",
"2": "2",
"from": "0x0000000000000000000000000000000000000000",
"to": "0xbD1d346577a444143E308BAbE1aa279e26e5f595",
"tokenId": "2"
}
so i went and called this function:
carbonFootprintInstance.methods.safeMint(address).send({
from:'0x0000000000000000000000000000000000000000',
gasPrice: web3.utils.toHex(0),
gasLimit: web3.utils.toHex(5000000)
})
but it tells me that the account doesnt exist. I want the nft to be created from scratch (hence the 0x000 account) and assign it to someone (the "address" variable).
It works perfectly if instead of the 0x000 account i put an existing one, but is there any way to use the 0x0000?