Create NFTs using an API. The same API used to power Arthouse (source code).
cp shared.env .env
Set your desired environment variables and private
yarn install
yarn dev
Note: Comment out checkAPIKeyCredits
middleware in handler.ts
if you don't want to make your API require an API Key.
body('chainId').isLength({ min: 1 }),
checkAPIKeyCredits, // <---- comment this line if you don't want your API to require an API key
async (req: Request, res: Response) => {
curl --location --request POST 'https://vxherrwkab.execute-api.us-east-1.amazonaws.com/staging/api/v1/nft' \
--header 'X-ATILA-API-CREDITS-KEY: [YOUR_API_KEY_FROM_art.atila.ca/settings]' \
--header 'Content-Type: application/json' \
--data-raw '{
"nfts": [
{
"nft": {
"name": "Atila Landing Page Banner [Rinkeby]",
"description": "The landing page banner image for atila.ca",
"image": "https://atila.ca/static/media/landing-cover-default.4fd96d95.png",
"chainId": "4",
"owner": "0x27F7e8d7C63C414Eae2BB07E1a9B9057a1D382cf"
}
},
{
"nft": {
"name": "Atila Landing Page Banner [Polygon]",
"description": "The landing page banner image for atila.ca",
"image": "https://atila.ca/static/media/landing-cover-default.4fd96d95.png",
"chainId": "137",
"owner": "0x27F7e8d7C63C414Eae2BB07E1a9B9057a1D382cf"
},
}
]
}'
npx hardhat test
Test a specific feature: npx hardhat test --grep unListMarketItem
Sometimes you might try to run a test or a piece of code and find that a function is undefined. This might be due to an outdated artifacts build. Run npx hardhat compile --force
to force a recompilation.
- Deploys to AWS Lambda
- Staging Lambda Console
- Set environment variables:
INFURA_API_KEY
andCONTRACT_DEPLOYMENT_WALLET_PRIVATE_KEY
To quickly run commands you can use the interactive hardhat console
npx hardhat console
const [ownerSigner, signer1, signer2] = await ethers.getSigners();
const ownerBalance = await ethers.provider.getBalance(ownerSigner.address);
-
If you won't be deploying to a test net or mainnet, go to
hardhat.config.js
and comment outprivateKey
and all the networks except fornetworks.hardhat
-
Put your private keys for the account that will be deploying the smart contract in a
.secrets
file. This will NOT be included in your version control. You can get the key fromshared.secrets
and runcp shared.secrets .secrets
and replace the private key. -
Load the secret key
source .secrets
-
Compile the smart contracts to get the most recent change:
npx hardhat compile
-
Run your own local blockchain node using:
npx hardhat node
-
Put your private keys for the account that will be deploying the smart contract in
.privateKey
. This will NOT be included in your version control and runsource .env
. -
Add the chain information to
src/config-chains.json
- Get Chain ID from:
- Get an RPC URL for your desired blockchain (TODO: where to get good RPC urls)
- Binance: https://docs.binance.org/smart-chain/developer/rpc.html (TODO: add other chains)
- Add the apikey to
.secrets
-
Get some tokens to pay the gas fees for deploying the smart contracts. On testnets you can use a faucet:
- Ethereum Rinkeby: https://rinkebyfaucet.com
- Binance: https://testnet.binance.org/faucet-smart
- Polygon: https://faucet.polygon.technology
- Celo: https://celo.org/developers/faucet
-
Load secrets to your environment variable
source .env
-
Deploy the smart contract:
npx hardhat deploy --chain-id [chainId]
- If you want to deploy just the NFT or the Market without deploying everything run:
npx hardhat deploy:nft --chain-id [chainId]
npx hardhat deploy:market --chain-id [chainId]
- Here are some examples:
- Ethereum Rinkeby:
npx hardhat deploy --chain-id 4
- Ethereum Rinkeby NFT only:
npx hardhat deploy:nft --chain-id 4
- Binance Smart Chain Testnet:
npx hardhat deploy --chain-id 97
- Polygon Mumbai:
npx hardhat deploy --chain-id 80001
- If you want to deploy just the NFT or the Market without deploying everything run:
If the deploy script is not working you can also us the default hardhat deployment script. Make sure to update the CHAIN ID variable: TODO add a check that chainID matches the passed in network
npx hardhat run --network polygon scripts/deploy-hardhat.js
- Add the new chain information to
README.md
, see these commits below for examples of what to change:
- Get Etherscan API Key: https://etherscan.io/myapikey
- Similar process for BSC Scan, PolygonScan etc
- Set environment variable in
.secrets
:export ETHERSCAN_API_KEY=""
npx hardhat verify --network rinkeby [smart_contract_address_you_just deployed]
- Example:
npx hardhat verify --network rinkeby 0x5f3cc650c751fa194f0d1537ecfbb55a2c40a995
- To see a list of other networks:
npx hardhat verify --list-networks
- Example:
Note: That the hardhat.config.js
expects the network name to be camelcase e.g. bscTestnet: BSCSCAN_API_KEY
,
but when you run the command it should be all lowercase: npx hardhat verify --network bsctestnet [ADDRESS]
-
Add the chain information to
src/config-chains.json
- Get Chain ID from:
- Get an RPC URL for your desired blockchain (TODO: where to get good RPC urls)
- Binance: https://docs.binance.org/smart-chain/developer/rpc.html (TODO: add other chains)
- Add the apikey to
.secrets
-
Get some tokens to pay the gas fees for deploying the smart contracts. On testnets you can use a faucet:
- Ethereum Rinkeby: https://rinkebyfaucet.com
- Binance: https://testnet.binance.org/faucet-smart
- Polygon: https://faucet.polygon.technology
- Celo: https://celo.org/developers/faucet
The following smart contract details is auto-generated using src/config-chains.json
Autogenerate the following section by running: node scripts/add-chains-info-to-readme.js
- Smart Contract
- Chain ID: 4
- Faucets: https://rinkebyfaucet.com
- Smart Contract
- Chain ID: 56
- Smart Contract
- Chain ID: 97
- Faucets: https://testnet.binance.org/faucet-smart
- Smart Contract
- Chain ID: 137
- Smart Contract
- Chain ID: 44787
- Smart Contract
- Chain ID: 80001
If you see, the following doublecheck you set the correct credentials for your RPC URL:
Invalid JSON-RPC response received: {
"message":"Invalid authentication credentials"
}
{
"nfts": [
{
"nft": {
"name": "Atila Landing Page Banner [Rinkeby]",
"description": "The landing page banner image for atila.ca",
"image": "https://ipfs.infura.io/ipfs/QmbMnVTAiX444S5yZS5MHNgiCk1b8Ff7muWmEnLVXRJYY9",
"tokenId": 9,
"tokenURI": "https://ipfs.infura.io/ipfs/Qmcx7XTUf1dhdbgtHaPWjvdPkZCNx2XprkPy5HJ7RHX229"
},
"blockExplorerUrl": "https://rinkeby.etherscan.io/token/0x5f3cc650c751fa194f0d1537ecfbb55a2c40a995?a=9",
"marketplaceUrls": [
"https://testnets.opensea.io/assets/rinkeby/0x5f3cc650c751fa194f0d1537ecfbb55a2c40a995/9",
"https://rinkeby.rarible.com/token/0x5f3cc650c751fa194f0d1537ecfbb55a2c40a995:9",
"https://rinkeby.looksrare.org/collections/0x5f3cc650c751fa194f0d1537ecfbb55a2c40a995/9",
"https://testnets.nftrade.com/assets/rin/0x5f3cc650c751fa194f0d1537ecfbb55a2c40a995/9"
],
"transaction": {
"hash": "0xcbaf604a43b3c171a320922aa8c129a831db80d0f705636ec09e4223f04d32af",
"to": "0x5f3cc650c751Fa194F0d1537ECFBb55a2c40a995",
"from": "0x518CfB8892F895EDCe659D46995ebC10e025c1dE",
"gasUsed": {
"type": "BigNumber",
"hex": "0x024dea"
},
"url": "https://rinkeby.etherscan.io/tx/0xcbaf604a43b3c171a320922aa8c129a831db80d0f705636ec09e4223f04d32af"
}
},
{
"nft": {
"name": "Atila Landing Page Banner [Polygon]",
"description": "The landing page banner image for atila.ca",
"image": "https://ipfs.infura.io/ipfs/QmbMnVTAiX444S5yZS5MHNgiCk1b8Ff7muWmEnLVXRJYY9",
"tokenId": 9,
"tokenURI": "https://ipfs.infura.io/ipfs/QmWMKJNAZfBW2QVvALK55B681Vo8iCoA1whckPzxic9c4S"
},
"blockExplorerUrl": "https://polygonscan.com/token/0x4ad4ab97820137e75ef98fc29ee0e9077130e905?a=9",
"marketplaceUrls": [
"https://opensea.io/assets/matic/0x4ad4ab97820137e75ef98fc29ee0e9077130e905/9",
"https://nftrade.com/assets/polygon/0x4ad4ab97820137e75ef98fc29ee0e9077130e905/9"
],
"transaction": {
"hash": "0x03994773579fb1798305a884ac76df076e0644502278ab4ad959c854532713b1",
"to": "0x4ad4ab97820137e75Ef98FC29Ee0e9077130E905",
"from": "0x518CfB8892F895EDCe659D46995ebC10e025c1dE",
"gasUsed": {
"type": "BigNumber",
"hex": "0x024dea"
},
"url": "https://polygonscan.com/tx/0x03994773579fb1798305a884ac76df076e0644502278ab4ad959c854532713b1"
}
}
],
"search_credits_available": 600
}