Scrypt Boilerplate
Last updated
Was this helpful?
Last updated
Was this helpful?
Note: Modified to use @radiantblockchian/radjs for testnet/superAssetR100.js
Make sure you have the installed. sCrypt IDE is a tool for developers to write, test, deploy, call, and debug sCrypt smart contracts.
is a high-level programming language for writing smart contracts on Bitcoin SV. This project provides examples to help developers learn and integrate sCrypt smart contracts to their Javascript-based projects. Our recommended procedure of developing smart contract based applications is as follows:
Contract Development and Test
Contract Integration and Application Launch
After developing and unit testing the smart contracts, the next step is to integrate them into your application which is written in other languages such as Javascript or Python. Integration tests should be run on Bitcoin SV or before launching the application to the public on mainnet.
For each contract x
, a source file is at contracts/x.scrypt
, a test file is at tests/js/x.scrypttest.js
, and a deployment file is at testnet/x.js
.
The major steps to write a sCrypt test are exemplified by tests/demo.scrypttest.js
.
Use the imported function buildContractClass
to get a reflected contract, which has same properties and methods as defined in the specified sCrypt contract.
Note that demo_desc.json
is the description file name of the compiled contract, which will be generated automatically if you run npm run watch
and its name follows the rule $contractName_desc.json
.
Initialize the contract.
Write tests for the instantiated contract as you would do in Javascript.
Run unit tests file within the editor/explorer context menu.
Tests could also be run from the console by executing npm test
, just like regular Javascript/TypeScript tests.
Provide a private key with funds in privateKey.js
Deploy a contract and call its function by issuing
Output like the following will appear in the console. And you have successfully deployed a contract and called its function on Bitcoin. Sweet!
It is strongly recommended to test your contract on testnet first, before deploying it on mainnet. By default, deployment is on testnet. To switch to mainnet, simply modify API_PREFIX
in helper.js
.
IDE provides a universal UI interface. You can deploy the contract with one click by simply filling in the relevant parameters. You can call the public function of the contract with the click of a button without writing a line of code.
Install and import / require , which is a javascript SDK for integrating sCrypt smart contract.
Before deploying a contract, make sure the latest contract has been compiled to a , which is what will get deployed. This could be done automatically by running a daemon process with command npm run watch
. It will monitor a contract file's change and recompile it when necessary. All generated description files are located at testnet/fixture/autoGen
. Make sure it's up to date with the contract before deployment.