Skip to content

Template file for solidity smart contract Testing to ensure the contract is fit and fine for Mainnet deployment ( Note: Template uses EthersJS instead of Web3JS )

Notifications You must be signed in to change notification settings

milinddholakia/SolidityTestBase

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SOLIDITY SMART CONTRACT TESTING BASE FILE TEMPLATE

Steps for Testing

Step 1 : git clone https://github.com/jetsoanalin/SolidityTestBase.git

Step 2 : cd SolidityTestBase

Step 3 : npm i

Step 5 npm run test

If you want to Deploy it in Blockchain testnet rather than Ganache then Follow these steps :

Deploy Networks : rinkeby or kovan using the deploy.js script. Do node deploy.js deployall <network-name> <private-key>. Eg : node deploy.js deployall rinkeby 0xf67ea7b3f291950cd29559f56d54ba46ba1dc5072c6747c09d4d64f456f76798.

Note : The Deploying wallet should have enough Ether balance in it if not use online faucets to get some test ethers.

Using Template file

Step 1 : Signin to your Github Account.

Step 2 : Click here : https://github.com/Jetsoanalin/SolidityTestBase/generate and create a new Repository.

Step 3 : Clone the project and start modifying it.

Step 4 : Delete basic.sol from contracts folder. Create your smart contract file with it's appropriate name, e.g. bank.sol. This file uses 0.5.16 version of solidity pragma solidity 0.5.16.

Step 5 : Compile the Contract node compile.js the JSON file will be generated in build file.

Step 6 : Go to test folder Change the file name basic.test.js to your contract specific name eg: bank.test.js

Step 7 : Wtite your own test in basic.test.js

Step 8 : npm run test this will compile and run your tests.

Steps to deploy contract

  • You can test deployment on testnets like rinkeby or kovan. For deployment on mainnet use homestead, the process would be same as testnet, the deployment time might vary on different networks.

  • To deploy all compiled contracts, do node deploy.js deployall rinkeby 0xa6779f54dc1e9959b81f448769450b97a9fcb2b41c53d4b2ab50e5055a170ce7.

  • To deploy a specific contract, write it's JSON file name instead of deployall flag, e.g. node deploy.js SimpleStorage_0.json rinkeby 0xa6779f54dc1e9959b81f448769450b97a9fcb2b41c53d4b2ab50e5055a170ce7.

  • If the contract requires constructor arguments, you can pass it by adding them after the command, e.g. node deploy.js SimpleStorage_0.json rinkeby 0xa6779f54dc1e9959b81f448769450b97a9fcb2b41c53d4b2ab50e5055a170ce7 "Params".

Credits

About

Template file for solidity smart contract Testing to ensure the contract is fit and fine for Mainnet deployment ( Note: Template uses EthersJS instead of Web3JS )

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%