0

I'm using IPFS as a decentralized storage to store metadata for NFTs, which users set manually on the frontend by filling out a form. The metadata contains images, PDFs, and the name and description of the NFT. I'd like to use AWS S3 instead of IPFS for storing the metadata. I haven't found a straightforward tutorial or documentation on how to push the metadata to AWS S3 and generate a URI that will be used to mint the NFT in ReactJs

Can you help me with how to achieve the above, as well as share any resources or docs that might help?

Thank you.

2 Answers 2

0
// SPDX-License-Identifier: MIT
// Compatible with OpenZeppelin Contracts ^5.0.0
pragma solidity ^0.8.20;

import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

contract MyToken is ERC721, ERC721URIStorage, Ownable {
    constructor(address initialOwner)
        ERC721("MyToken", "MTK")
        Ownable(initialOwner)
    {}

    function safeMint(address to, uint256 tokenId, string memory uri)
        public
        onlyOwner
    {
        _safeMint(to, tokenId);
        _setTokenURI(tokenId, uri);
    }

    // The following functions are overrides required by Solidity.

    function tokenURI(uint256 tokenId)
        public
        view
        override(ERC721, ERC721URIStorage)
        returns (string memory)
    {
        return super.tokenURI(tokenId);
    }

    function supportsInterface(bytes4 interfaceId)
        public
        view
        override(ERC721, ERC721URIStorage)
        returns (bool)
    {
        return super.supportsInterface(interfaceId);
    }
}
  • Mint your token with aws-s3 endpoint as long as your endpoint returns your nft metadata
await contract.safeMint(receiver, tokenId, your_aws_s3_endpoint_for_token_id)
0

You can store the NFT metadata on Amazon S3 and expose a URI to access that content via Amazon API Gateway backed by a Lambda authoriser that determines who can access that content.

This blog provided by AWS might be helpful.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.