Skip to content

Latest commit

 

History

History
90 lines (40 loc) · 4.04 KB

README.md

File metadata and controls

90 lines (40 loc) · 4.04 KB

solidity-auction

July 2022

OVERVIEW

Solidity-auction is a decentralized application that allows for the minting of an Nft, and its sale via auction. To accomplish this, two contracts are required. The first, Nft.sol, will be used to mint the Nft and track its ownership. Additionally it will allow the seller to list the second contract, Auction.sol, to sell the Nft on the seller’s behalf. At the end of the auction, Auction.sol will transfer ownership of the Nft to the buyer, and compensate the seller with the winning bid amount. Nft.sol inherits from the ERC721 OpenZeppelin contract. Auction.sol is a custom contract that provides all auction functionality. It has a reference to Nft.sol, and implements the OpenZeppelin IERC721 Interface for token management.

APPROACH

Auction was developed using Solidity and the Truffle Suite, and is deployed to a local Ganache Blockchain. Auction can also be deployed to the Ethereum Blockchain on Mainnet once security audits have been completed and the application is shown to be production ready.

TESTING

All functional and unit testing was performed programmatically using Truffle, web3.js, the mocha framework and chai assertion library.

In order to be able to test in a step-by-step fashion using Auction.test.1.js, Auction.test.2.js, etc; truffle-config.js was modified to have both test and deploy network entries. By default, Truffle invokes the deployment process when running tests, which wipes out the prior contract instances to create a “clean-room” effect.

However, to maintain the originally deployed contracts and view their current state in ganache after each individual test, a routine was created to save the original deployment addresses of Nft.sol and Auction.sol, and use them to get a reference to the existing contracts rather than re-create them.

In addition, Auction.test.js can be run in isolation to execute all tests in a single invocation to ensure they are all passing as expected.

Dependencies

Node.js: https://nodejs.org/en/ (recommended v14.16.0)

Truffle: https://www.trufflesuite.com/ (recommended v5.5.18)

Ganache: https://www.trufflesuite.com/ganache

Metamask: https://metamask.io/

Installation

git clone git@github.com:git@github.com:rfarina/solidity-auction.git solidity-auction

npm install -g truffle@5.5.18

npm install

Download, Install and run ganache to establish the Blockchain for local testing

https://trufflesuite.com/ganache/

Test truffle installation

truffle version (should result in the following):

Truffle v5.5.18 (core: 5.5.18)

Ganache v7.2.0

Solidity v0.8.15 (solc-js)

Node v14.16.0

Web3.js v1.5.3

Compilation

Make sure ganache is started

truffle compile

Deployment to Ganache

truffle migrate --reset --network=deploy

Unit Testing - single pass

truffle test test/Auction.test.js --network=test

Unit Testing - incremental testing

truffle test test/Auction.test.01.js --network=test

(followed by Auction.test.02.js thru Auction.test.16.js)

End of Document