# Surfboard
Surfboard is a command line interface for working with Ride smart contracts and the Waves blockchain.
Key features:
- Ride smart contracts compilation.
- Ride REPL interactive console.
- Running JavaScript tests and scripts.
Surfboard provides built-in JavaScript functions for interaction with the Waves blockchain: signing and sending transactions, reading blockchain data, working with account keys and others. See the list of functions of js-test-env.
# Installation and Configuration
Download and install Node.js: https://nodejs.org/en/download/.
Install Surfboard:
npm i -g @waves/surfboard@latest
💡 Beta version of Surfboard supports new features of Waves protocol which are now available on Stagenet only:
npm i -g @waves/surfboard@beta
Create an empty folder and run the following command:
surfboard init
The command will create the project structure:
- the
ride
folder containing the dApp script example, - the
script
folder containing the JS script example that assigns the dApp script to account, - the
test
folder containing the JS test example, - the
surfboarf.config.json
file containing the settings for blockchain operation.
To configure the settings, edit the surfboarf.config.json
file or use the following command:
surfboard config:change KEY VALUE
- The file supports multiple environments. Set the default environment using the
defaultEnv
parameter. - If necessary, change the blockchain network and node URL.
- Specify the seed phrase for your account.
💡 Working with a local node is described in the How to Build, Deploy and Test a Waves RIDE dApp article.
# Compiling Ride Script
You can write the script code using any text editor, for example, Visual Studio Code with Ride extension.
Before assigning the script to an account or asset, compile it. Use the built-in JS function compile
(see the example of in the script
folder), or the following command:
surfboard compile FILE
For example:
surfboard compile ride/wallet.ride > wallet.compiled
This command compiles the Ride script example and writes it to the wallet.compiled
file in base64. This output can be included in the set script transaction.
# Assigning Ride Script to Account or Asset
You can send a set script transaction, issue transaction, or set asset script transaction by running JS script or JS test. To run JS script, use the command:
surfboard run FILE
For example:
surfboard run scripts/wallet.deploy.js --variables 'dappSeed=insert your seed here'
This command executes the JS script example that compiles the Ride script and sends the set script transaction from the account whose seed phrase is specified in the dappSeed
variable.
# Running Tests
In JS tests, you can use describe
, before
, it
, expect
and other functions of mocha and chai libraries. You can find test example in the test
folder.
To run test, use the command:
surfboard test FILE
# Ride REPL: Interactive Console
Ride REPL is the easiest way to try out the Ride language and its execution semantic.
To run Ride REPL, use the command:
surfboard repl
💡 Run the .editor
command to enter multiline mode so you can type or paste a larger code block or multiple definitions.
To leave REPL, run the .exit
command.
# All Surfboard Commands
See the list of commands in Surfboard repository on GihHub.