Skip to content

Commit

Permalink
Running script with Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
ineiti committed Dec 6, 2023
1 parent b079cab commit 77d8cbb
Show file tree
Hide file tree
Showing 25 changed files with 278 additions and 317 deletions.
Empty file removed .env
Empty file.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ __pycache__
.hypothesis/
build/
reports/
.env
operations.log
.idea
26 changes: 18 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
FROM python:3.9

WORKDIR /root
RUN curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
RUN . /root/.bashrc
ENV NVM_DIR /root/.nvm
ENV NODE_VERSION v18.19.0
ENV PATH $NVM_DIR/versions/node/$NODE_VERSION/bin:$PATH
RUN . $NVM_DIR/nvm.sh && \
nvm install 18 && npm install i -g ganache
RUN pip install eth-brownie
WORKDIR /root
nvm install $NODE_VERSION && npm install i -g ganache

COPY requirements.txt .
RUN pip install -r requirements.txt

RUN touch .env
COPY . ./
#COPY brownie-config.yaml ./
#COPY contracts contracts/
RUN . $NVM_DIR/nvm.sh && \
brownie compile
COPY brownie-config.yaml .
COPY contracts contracts/
COPY scripts/sepolia.network .

RUN brownie compile
RUN brownie networks import sepolia.network
RUN rm -rf *

WORKDIR /sismondi
ENTRYPOINT ["/usr/local/bin/brownie"]
74 changes: 72 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,77 @@ On utilisera ici le porte-feuille le plus connu: Metamask.

### Installation Metamask

[Metamask](https://metamask.io/)

### Faucets:
https://sepolia-faucet.pk910.de
[Faucet](https://sepolia-faucet.pk910.de)

### Etherscan

[Etherscan](https://sepolia.etherscan.io)

## NFTs

### Intro

### Préparation des images

- Utiliser le script [scripts/images.py]
- Entrer les images dans [scripts/sismondi.py]

### Création d'un contrat NFT

Localement sur la chaîne de développement:

```bash
./brownie.sh run sismondi.py deploy
```

Avec un `--network sepolia` à la fin, c'est plus sérieux: on va se mettre sur la chaîne de test.

### Minter un NFT

Localement sur la chaîne de développement:

```bash
./brownie.sh run sismondi.py deploy_mint
```

Ou sur la chaîne de test:

```bash
./brownie.sh run sismondi.py mint 0xcontract_id_in_hex --network sepolia
```

## Utilisation des NFTs

### Ajout au portefeuille Metamask

### Suivi dans OpenSea

https://opensea.io/

### Envoi vers d'autres utilisateurs

???

## Installation locale

Pour l'installation locale, il faut commencer à installer docker:

[Commencer avec Docker](https://www.docker.com/get-started/)

Puis on peut préparer l'image avec:

```
docker compose build
```

Après on peut utiliser `./brownie.sh`

## Documentation

### Etherscan
- Howto on which the hands-on is based: [Deploy Your First NFT With Python](https://www.codeforests.com/2022/01/14/deploy-your-first-nft-with-python/) -
[Github with contract](https://github.com/codeforests/brownie_legendnft)
- Contract used in the hands-on: [openzeppelin-contracts](https://github.com/OpenZeppelin/openzeppelin-contracts/tree/master)
[Definition of ERC 721](https://docs.openzeppelin.com/contracts/4.x/api/token/erc721)
4 changes: 2 additions & 2 deletions brownie-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ compiler:
dotenv: .env

networks:
rinkeby:
sepolia:
verify : false
development:
verify : false

wallets:
from_key: ${PRIVATE_KEY}
from_key: ${PRIVATE_KEY}
3 changes: 3 additions & 0 deletions brownie.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

docker run --rm --platform linux/amd64 -v $PWD:/sismondi c4dt/brownie:latest "$@"
110 changes: 0 additions & 110 deletions contracts/LegendNFT.sol

This file was deleted.

81 changes: 81 additions & 0 deletions contracts/SismondiNFT.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
// SPDX-License-Identifier: UNLICENSED

pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
import "@openzeppelin/contracts/utils/Counters.sol";


import {Base64} from "./libraries/Base64.sol";

contract SismondiNFT is ERC721URIStorage {

using Counters for Counters.Counter;
Counters.Counter private _tokenIds;

uint256 public totalSupply;

string[] images = [
"iVBORw0KGgoAAAANSUhEUgAAABQAAAANCAYAAACpUE5eAAABhGlDQ1BJQ0MgUHJvZmlsZQAAeJx9kT1Iw0AcxV9ba0UqHewg4pChumgXFXGsVShChVArtOpgcukXNGlIUlwcBdeCgx+LVQcXZ10dXAVB8APE1cVJ0UVK/F9SaBHjwXE/3t173L0D/M0qU82eBKBqlpFJJYVcflUIvSKMICLoxbjETH1OFNPwHF/38PH1Ls6zvM/9OQaUgskAn0CcYLphEW8Qz2xaOud94igrSwrxOfGEQRckfuS67PIb55LDfp4ZNbKZeeIosVDqYrmLWdlQiaeJY4qqUb4/57LCeYuzWq2z9j35C8MFbWWZ6zRHkMIiliBCgIw6KqjCQpxWjRQTGdpPeviHHb9ILplcFTByLKAGFZLjB/+D392axalJNymcBIIvtv0xCoR2gVbDtr+Pbbt1AgSegSut4681gdlP0hsdLXYERLaBi+uOJu8BlzvA0JMuGZIjBWj6i0Xg/Yy+KQ8M3gL9a25v7X2cPgBZ6ip9AxwcAmMlyl73eHdfd2//nmn39wNld3KhWalQEAAAAgtJREFUeJytk8FLVFEUh79773uvGWec5pmmplhpVtJCV+miEIJaR9uWbaRVFLSsRRBt+gtaRbSSINy1K4iCFlaLEDQqRkxHyXHUaea9d989LWYQIxcK/eBw4MD54PzOOSociIT/KO+gDVY0idP/1H3t8JQ7GNCKZrTwi8tHF9myPlmTYp1GlPB6rY8vWx0HA6aiuDv8kSvdJUq1AoloAp1yKr/B09JZpj5N7h9oRdMRNJgIy9yfG2dm+Tg9md/Mbxd5e/ElS/U8AvxlRuwM9dTbiUZqiJzZ8ex6/wI5zzK70cmTsTdMhKs4FAUvZqFWQNFaigAiigtHlhnJVxjMbRL6EZ52FP2YjE4p+jHD+QqPv45x7dg3xjvKoIRAp61FGUCawNh63Oqf48HIB1YabawkWdaTACuaSi1H1li62mOmS6d5t9bL1d4fKKvBesyvd5LrVxjXnNLDaQ6FW1Rvz3BDw6v356kvdpPU84gSYmcY9avc61qh7/ASD4e+ExthqnyGF6uDeCerPJ9cpL5+Dv1To8LeVBgpEU0/Qoo1Ah2hAIXZ8dY5gyQGHflkcKSeo2Yg0Cn4CTGWzJ2byLNLqHAgEgTo2oRwG3oqcKIMuQaIahKzEdIWQXsd8S0qClCbbU33qzn4PAizQ9AIWkCAVINT4Fp5L+0u735YLRBYULLrDo2jOWW639PcU38A4A3X9hp5mjkAAAAASUVORK5CYII="
];
string[] wordList = ["One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight"];

event NewSismondiNFTMinted(address sender, uint256 tokenId);


constructor() ERC721 ("Codeforests Sismondi", "CFL") {
totalSupply = 1000000;
}

function pickRandomWord(uint256 tokenId) internal view returns (string memory) {
uint256 rand = random(string(abi.encodePacked("WORD", Strings.toString(tokenId))));
rand = rand % wordList.length;
return wordList[rand];
}

function random(string memory input) internal pure returns (uint256) {
return uint256(keccak256(abi.encodePacked(input)));
}

function makeSismondiNFT() public {
uint256 newItemId = _tokenIds.current();
require(newItemId < totalSupply, "Total supply has been reached!");

string memory randomWord = pickRandomWord(newItemId);

string memory TOKEN_JSON_URI = getTokenURI(randomWord, images[0]);

_safeMint(_msgSender(), newItemId);
_setTokenURI(newItemId, TOKEN_JSON_URI);
_tokenIds.increment();
emit NewSismondiNFTMinted(_msgSender(), newItemId);
}

function getTokenURI(string memory words, string memory pngString) internal pure returns (string memory) {

string memory json = Base64.encode(
bytes(
string(
abi.encodePacked(
'{"name": "',
words,
'", "description": "A Sismondi NFT collection.",'
'"image": "data:image/png;base64,',
pngString,
'"}'
)
)
)
);

string memory finalTokenUri = string(
abi.encodePacked("data:application/json;base64,", json)
);

return finalTokenUri;
}

function getTotalNFTsMintedSoFar() public view returns (uint256) {
return _tokenIds.current();
}
}
22 changes: 0 additions & 22 deletions devbox.json

This file was deleted.

Loading

0 comments on commit 77d8cbb

Please sign in to comment.