How can I mint an NFT using ERC 721 directly to someone's wallet? I have done IPFS pinning for my NFT and am using truffle console to mint. I am able to mint the tokens but they are from my wallet only. I need it to be minted in the name of metamask logged user. Can someone help?
Asked
Active
Viewed 255 times
0
-
how did you write minftfunction in contract – Yilmaz May 15 '22 at 03:42
-
function claimItem(string memory tokenURI) public returns (uint256) { _tokenIds.increment(); uint256 newItemId = _tokenIds.current(); _safeMint(msg.sender, newItemId); // _safeMint(to, newItemId); _setTokenURI(newItemId, tokenURI); return newItemId; } – Chandan Kumar Jun 05 '22 at 16:57
1 Answers
0
To mint to a certain user, you'd have to add a parameter to your mint function.
function mint(address _to, ...) public payable {
// ...
_safeMint(_to, ...);
}
Something like this. And then in your dApp you'd simply add the connected wallet's address as the _to
parameter.

Martijn Vissers
- 712
- 5
- 29