Skip to content

bernardoaraujor/rusty-minty

Repository files navigation

Rusty Minty

A simplified Rusty rewrite of Minty. Provides a CLI utility to mint ERC721 NFTs under the Minty contract.

Assumptions:

Getting Started

$ git clone https://github.com/bernardoaraujor/rusty-minty
$ cd rusty-minty
$ npm install
$ npx hardhat compile

Run on Ethereum Rinkeby Testnet

First, get some tokens on Rinkeby Faucet.

For readability, the example below sets a few environment variables:

  • FILE: path to file to be uploaded to IPFS.
  • WEB3_PROV: URL to Web3 provider. Ex.: Infura endpoint, or local Ethereum node.
  • PRIV_KEY: the Minter account private key, without 0x prefix (warning: be careful!).
  • TOKEN_OWNER: the address of the NFT owner. It could be Minter or different account.
  • GAS_LIMIT: the max amount of Gas you're willing to pay to mint. The -g CLI arg is optional and defaults to 10000000.
  • CONTRACT_ADDR: the address of the Minty contract on the chain.
  • CONTRACT_ABI: path to Minty contract ABI artifact (.json). The -a CLI arg is optional and defaults to abi/contracts/Minty.sol/Minty.json, which is the standard (relative) path when compiling via Hardhat.
$ FILE=/path/to/file
$ WEB3_PROV=https://rinkeby.infura.io/v3/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
$ PRIV_KEY=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
$ TOKEN_OWNER=0xXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
$ GAS_LIMIT=10000000
$ CONTRACT_ADDR=0x784E34cf0d61459a298E0C5a1B62bEcd4dE66756
$ CONTRACT_ABI=abi/contracts/Minty.sol/Minty.json
$ cargo run -- -i $FILE \
               -w $WEB3_PROV \
               -p $PRIV_KEY \
               -o $TOKEN_OWNER \
               -g $GAS_LIMIT \
               -c $CONTRACT_ADDR \
               -a $CONTRACT_ABI
IPFS CID: QmVbZSaArBjQx9R55ihfmocMXaNcBTBCNqXtqzA9NdCzxE
Mint Tx: 0x835357b29b7e0fc60f7e279fa8ae03a968727a6256cc6667abe54f8a2bba29ec

Note: you should check the Tx hash on Etherscan to verify whether it was successful.

Note: you should pin your CID on your local node or some pinning service, otherwise it might disappear in the future.

Test on local Hardhat setup

You could also test on a local Hardhat setup.

First, start a Hardhat node:

$ npx hardhat node

On a new terminal, deploy the contract and take note of its address:

$ npx hardhat run scripts/deploy.js
Minty deployed to: 0x5FbDB2315678afecb367f032d93F642f64180aa3

Finally, run the CLI utility:

$ FILE=/path/to/file
$ WEB3_PROV=http://localhost:8545
$ PRIV_KEY=ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
$ TOKEN_OWNER=0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266
$ GAS_LIMIT=10000000
$ CONTRACT_ADDR=0x5FbDB2315678afecb367f032d93F642f64180aa3
$ CONTRACT_ABI=abi/contracts/Minty.sol/Minty.json
$ cargo run -- -i $FILE \
               -w $WEB3_PROV \
               -p $PRIV_KEY \
               -o $TOKEN_OWNER \
               -g $GAS_LIMIT \
               -c $CONTRACT_ADDR \
               -a $CONTRACT_ABI
IPFS CID: QmVbZSaArBjQx9R55ihfmocMXaNcBTBCNqXtqzA9NdCzxE
Mint Tx: 0x310d20ae797ee691feeb109dbc81233d81e71555fcd02f7032aad397b0525127