Congratulations! You've built your very first Bitcoin SV smart contract using sCrypt. Now, you will learn how to implement your contract into your Web3/dAPP application using Javascript. We are assuming that you have some basic knowledge of the front-end development.
The webapp
branch of the React App project tic-tac-toe contains a tic-tac-toe game with only front-end code. We will start from this branch and implement a contract version of tic-tac-toe game step by step.
scryptlib is sCrypt's official Javascript SDK for integrating Bitcoin SV Smart Contract in your application. It is designed to help you quickly build a high-quality Smart Contract applications. You will be able to compile, test, deploy and call contracts through this SDK.
scryptlib
can be installed via npm
.
// use NPM npm install scryptlib // use Yarn yarn add scryptlib
Here's how to instantiate Tic-Tac-Toe Smart Contract and call its pujblic methods. Just like regular Javascript objects, you can simply compile new contract class Tictactoe
, instantiate new object named game
using the class, and call the function called move
.
const Demo = buildContractClass(compileContract('demo.scrypt')); const demo = new Demo(7, 4); const result = demo.add(11).verify() assert(result.success);
Clone the React App project tic-tac-toe. and switch to the webapp
branch.