This tool allows fetching NFTs info from DB and store them in a JSON file and later restore them in to a new NFT contract.
This will store all NFTs for given contract_address
in a JSON file with timestamp.
You need to provide a DB_URL
env variable.
export DB_URL=postgres://user@pass:host[:5432]/dbname
npm run backup <source_contract_address>
This will restore all NFTs from a JSON file into a new contract.
You need to provide a private key for the contract admin account and a JSON RPC URL (default is http://127.0.0.1:8545
).
export ETH_PRIVATE_KEY=0x12312a122313123123123
# export JSON_RPC_URL=https://mainnet.infura.io/v3/123123123
npm run restore <destination_contract_address> <backup_json_filename>
We expect to have a perfect match between the NFT ids (object_id
field) in the JSON file and the NFTs in the contract. If there is a mismatch in the expected ID, the script will fail.
It can though detect the progress till ID X and skip the NFTs before X and continue with the rest.
Here's how to retrive the account's private key in MetaMask.