Skip to content

asseth/MembershipNFT

Repository files navigation

MembershipNFT

MembershipNFT for Ethereum-France

Table of content


Project structure

src/

Contains the contract implementation.

test/

Contains the contract tests implementation, in Solidity (using foundry testing framework).

lib/

Contains the code of the Solidity library used for implementation and testing. They are stored as git submodules (using foundry dependencies system).

script/nodejs/

Contains any utilitary scripts for interacting with the contract. You will find JS scripts for contract direct interaction and withpaper.com interaction.

How to use this repo?

To use this repo, you first need to install Foundry and nodejs.

Also, remember to clone the submodules as you initialize this repo, either by adding the --recurse-submodules parameter on clone or using the commands git submodule init and git submodule update.

To use the nodejs scripts, you will need environment variables filled in a .env file in the script/nodejs/ folder. See the .env.template file for more informations.

Please note that all blockchain interactions (contract deployment and transactions) use a wallet whose private key is provided in a .env file. I recommend using a burner wallet to avoid leaking and compromising your wallet.

### forge examples ###
# build the contract (you will then find the ABI and other data in the `out/` directory)
forge build

# run the tests
forge test

# export contract code
forge flatten src/SBT.sol

# Build & host locally the contract documentation
forge doc --build
forge doc --serve


### custom scripts ###
# NB: you can always run a script without argument to print the usage.
# NB: You must install the required libraries first:
cd script/nodejs
npm install

# Deploy the contract
cd script/nodejs
node contract/deployContract.js <NETWORK>

# Add a withpaper.com wallet address to the contract
cd script/nodejs
node contract/setWithPaperAddress.js <NETWORK> <CONTRACT ADDRESS> <WITHPAPER ADDRESS>

# Change the owner of the contract
cd script/nodejs
node contract/transferOwnership.js <NETWORK> <CONTRACT ADDRESS> <NEW OWNER ADDRESS>

# Change the token metadata URI
cd script/nodejs
node contract/updateMetadata.js <NETWORK> <CONTRACT ADDRESS> <METADATA URI>

# Register a contract on withpaper.com dashboard (can be down from the dashboard directly)
cd script/nodejs
node withPaper/registerContractInPaper.js <NETWORK> <CONTRACT ADDRESS>

# Create a checkout (mint) link
cd script/nodejs
node withPaper/createPaperCheckoutLink.js <PAPER_CONTRACT_ID> <CURRENCY>

How does it works ?

the MembershipNFT is a Soulbound Token, or SBT, used to represent a membership to the Ethereum France association. It acts as an on-chain certificate, allowing one to access to the Ethereum France community, for example.

The contract implementing this token is based on the EIP5192. It has also a withpaper.com integration, allowing the members to easily mint their token.

About function restrictions

The contract has certain functions restricted, for security purposes. 3 roles can be identified to explain these restrictions:

  • The owner, which is the deployer of the contract,
  • The minters, which are wallets managed by withpaper.com.
  • The members, which are the owners of their respective SBT.

Here are the restricted functions:

  • setWithPaperAddress(address addr, bool value) is restricted to the owner only. NB: it will in fact give the minter role to a new address
  • mint(address to) is restricted to minters and the owner.
  • burn(uint256 tokenId) is restricted to the member that own the token to burn and the owner of the contract.
  • setBaseURI(string memory tokenURI_) is restricted to the owner only.

Licence

Shield: CC BY-SA 4.0

This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

CC BY-SA 4.0

About

MembershipNFT for Ethereum-France

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published