TxocoCalPadri is a smart contract written in Solidity for the Ethereum Virtual Machine (EVM). It allows our gastronomic association to manage proposals and voting through the use of NFT tokens. Members of the association own an NFT which grants them the ability to vote on proposals. NFTs are managed by administrators and are non-transferable by token holders.
- Issuance and revocation of NFTs for members
- NFTs are non-transferable by members, only administrators can transfer them as membership is non-transferable
- Creation and management of proposals with voting options
- Members can vote on active proposals
Currently, there are 6 different NFTs issued: One for membership, another for an exchange trip to the Basque Country, and four for membership tenure. They are as follows:
This NFT certifies that the owner is a member of Txoco Cal Padrí
This NFT represents 1 year of membership
This NFT represents 2 years of membership
This NFT represents 3 years of membership
This NFT represents 4 years of membership
This NFT certifies that the owner participated in the trip to the Basque Country in March 2023
And of course, there are more to come!
Allows the contract owner to set the base URI for token metadata.
Allows the contract owner to add or remove administrators. Set _status
to true to add, false to remove.
Allows administrators to mint an NFT to a specific address, granting membership.
Allows administrators to revoke an NFT from a specific address, revoking membership.
createProposal(string memory _title, string memory _description, string[] memory _options, uint256 _startTime, uint256 _endTime)
Allows administrators to create a new proposal with title, description, array of voting options, and a time window for voting.
Allows administrators to officially close a proposal after its end time has passed.
Allows NFT holders to cast a vote on an active proposal by selecting an option.
Returns an array of vote counts for each option of a specific proposal.
Returns index, name, and vote count of winning option for a specific proposal.
ProposalCreated
: Emitted when a new proposal is created.Voted
: Emitted when a vote is cast on a proposal.NFTMinted
: Emitted when a new NFT is minted.
This contract overrides the following functions from its inherited contracts to adapt their behavior for the specific requirements of this contract:
Overrides the uri function from the ERC1155 contract. Used to get a token's metadata URI. However, this ignores the tokenId and returns the base URI for all tokens.
Overrides safeTransferFrom function from ERC1155 contract. Used to safely transfer tokens between addresses. Modified to only allow administrators to transfer tokens.
safeBatchTransferFrom(address _from, address _to, uint256[] memory _ids, uint256[] memory _values, bytes memory _data)
Overrides safeBatchTransferFrom from ERC1155 contract. Used to perform batch transfer of multiple tokens between addresses. Modified to only allow administrators to transfer tokens.
- Clone this repository
- Navigate to project folder and run
docker-compose build --no-cache
- Start containers with
docker-compose up -d
- Compile and run tests with
docker-compose run --rm txoco truffle test
- Run static code analysis with
docker-compose run --rm slither slither . --exclude-dependencies
MIT