mirror of
https://github.com/autistic-symposium/mev-toolkit.git
synced 2025-05-02 06:46:13 -04:00
move er721-101 to solidity dir
This commit is contained in:
parent
bb3dcb5b32
commit
ec24a4b414
8 changed files with 0 additions and 0 deletions
BIN
solidity/erc721-solidity-101/.DS_Store
vendored
Normal file
BIN
solidity/erc721-solidity-101/.DS_Store
vendored
Normal file
Binary file not shown.
5
solidity/erc721-solidity-101/.env_sample
Normal file
5
solidity/erc721-solidity-101/.env_sample
Normal file
|
@ -0,0 +1,5 @@
|
|||
API_URL = "https://eth-rinkeby.alchemyapi.io/v2/<project>"
|
||||
PUBLIC_KEY =
|
||||
PRIVATE_KEY =
|
||||
METADATA_URL = <pinata IPFS cid dor metadata>"
|
||||
CONTRACT_ADDRESS =
|
20
solidity/erc721-solidity-101/README.md
Normal file
20
solidity/erc721-solidity-101/README.md
Normal file
|
@ -0,0 +1,20 @@
|
|||
# One: A special summer
|
||||
|
||||
|
||||
1. Compile contract:
|
||||
|
||||
```
|
||||
npx hardhat compile
|
||||
```
|
||||
|
||||
2. Deploy contract:
|
||||
|
||||
```
|
||||
npx hardhat run scripts/deploy-contract.js --network rinkeby
|
||||
```
|
||||
|
||||
3. Mint NFT:
|
||||
|
||||
```
|
||||
node scripts/mint-nft.js
|
||||
```
|
28
solidity/erc721-solidity-101/contracts/MiaNFT.sol
Normal file
28
solidity/erc721-solidity-101/contracts/MiaNFT.sol
Normal file
|
@ -0,0 +1,28 @@
|
|||
// SPDX-License-Identifier: MIT
|
||||
pragma solidity >=0.7.3 <0.9.0;
|
||||
|
||||
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
|
||||
import "@openzeppelin/contracts/utils/Counters.sol";
|
||||
import "@openzeppelin/contracts/access/Ownable.sol";
|
||||
|
||||
|
||||
contract MiaNFT is ERC721, Ownable {
|
||||
|
||||
using Counters for Counters.Counter;
|
||||
Counters.Counter private _tokenIds;
|
||||
|
||||
constructor() public ERC721("Mia's NFT, "NFT") {}
|
||||
|
||||
function mintNFT(address recipient, string memory tokenURI)
|
||||
public onlyOwner
|
||||
returns (uint256)
|
||||
{
|
||||
_tokenIds.increment();
|
||||
|
||||
uint256 newItemId = _tokenIds.current();
|
||||
_mint(recipient, newItemId);
|
||||
_setTokenURI(newItemId, tokenURI);
|
||||
|
||||
return newItemId;
|
||||
}
|
||||
}
|
19
solidity/erc721-solidity-101/hardhat.config.js
Normal file
19
solidity/erc721-solidity-101/hardhat.config.js
Normal file
|
@ -0,0 +1,19 @@
|
|||
/**
|
||||
* @type import('hardhat/config').HardhatUserConfig
|
||||
*/
|
||||
require('dotenv').config();
|
||||
require("@nomiclabs/hardhat-ethers");
|
||||
|
||||
const { API_URL, PRIVATE_KEY } = process.env;
|
||||
|
||||
module.exports = {
|
||||
solidity: "0.7.3",
|
||||
defaultNetwork: "rinkeby",
|
||||
networks: {
|
||||
hardhat: {},
|
||||
rinkeby: {
|
||||
url: API_URL,
|
||||
accounts: [`0x${PRIVATE_KEY}`]
|
||||
}
|
||||
},
|
||||
}
|
23
solidity/erc721-solidity-101/package.json
Normal file
23
solidity/erc721-solidity-101/package.json
Normal file
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
"name": "MiaNFT",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "Mia von Steinkirch",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@nomiclabs/hardhat-ethers": "^2.0.2",
|
||||
"@nomiclabs/hardhat-waffle": "^2.0.1",
|
||||
"@openzeppelin/contracts": "^3.1.0-solc-0.7",
|
||||
"chai": "^4.3.4",
|
||||
"ethereum-waffle": "^3.4.0",
|
||||
"ethers": "^5.4.6",
|
||||
"hardhat": "^2.6.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"@alch/alchemy-web3": "^1.1.4",
|
||||
"dotenv": "^10.0.0"
|
||||
}
|
||||
}
|
14
solidity/erc721-solidity-101/scripts/deploy-contract.js
Normal file
14
solidity/erc721-solidity-101/scripts/deploy-contract.js
Normal file
|
@ -0,0 +1,14 @@
|
|||
async function main() {
|
||||
const nft = await ethers.getContractFactory("MiaNFT");
|
||||
|
||||
const nft_deploy = await nft.deploy();
|
||||
console.log(" ⛓🧱✨ Contract address:", nft_deploy.address);
|
||||
console.log(" ➡️ (Please add this string to .env)");
|
||||
}
|
||||
|
||||
main()
|
||||
.then(() => process.exit(0))
|
||||
.catch(e => {
|
||||
console.error(e);
|
||||
process.exit(1);
|
||||
});
|
41
solidity/erc721-solidity-101/scripts/mint-nft.js
Normal file
41
solidity/erc721-solidity-101/scripts/mint-nft.js
Normal file
|
@ -0,0 +1,41 @@
|
|||
require('dotenv').config();
|
||||
|
||||
const PUBLIC_KEY = process.env.PUBLIC_KEY;
|
||||
const PRIVATE_KEY = process.env.PRIVATE_KEY;
|
||||
const API_URL = process.env.API_URL;
|
||||
const METADATA_URL = process.env.METADATA_URL;
|
||||
const CONTRACT_ADDRESS = process.env.CONTRACT_ADDRESS;
|
||||
const { createAlchemyWeb3 } = require("@alch/alchemy-web3");
|
||||
const web3 = createAlchemyWeb3(API_URL);
|
||||
const contract = require("../artifacts/contracts/MiaNFT.sol/MiaNFT.json");
|
||||
const nftContract = new web3.eth.Contract(contract.abi, CONTRACT_ADDRESS);
|
||||
|
||||
async function mintNFT(tokenURI) {
|
||||
|
||||
const nonce = await web3.eth.getTransactionCount(PUBLIC_KEY, 'latest');
|
||||
|
||||
const transaction = {
|
||||
'from': PUBLIC_KEY,
|
||||
'to': CONTRACT_ADDRESS,
|
||||
'nonce': nonce,
|
||||
'gas': 500000,
|
||||
'maxPriorityFeePerGas': 1999999987,
|
||||
'data': nftContract.methods.mintNFT(PUBLIC_KEY, tokenURI).encodeABI()
|
||||
};
|
||||
|
||||
const sign = web3.eth.accounts.signTransaction(transaction, PRIVATE_KEY);
|
||||
sign.then((signedTransaction) => {
|
||||
|
||||
web3.eth.sendSignedTransaction(signedTransaction.rawTransaction, function(e, hash) {
|
||||
if (!e) {
|
||||
console.log("💾 Transaction hash: ", hash);
|
||||
} else {
|
||||
console.log("ERROR:", e)
|
||||
}
|
||||
});
|
||||
}).catch((e) => {
|
||||
console.log("ERROR:", e);
|
||||
});
|
||||
}
|
||||
|
||||
mintNFT(METADATA_URL);
|
Loading…
Add table
Add a link
Reference in a new issue