Complete the exercise in index.js
in the folder Lab-DoubleCounter-Exercise
by adding code and values as necessary.
The index.js
file contains Lumos code to deploy, create, and consume cells using the Counter type script. Your task is to modify the functionality of this code to use the Double Counter type script.
- Compile the
doublecounter
binary from the previous lab in release mode usingcapsule build --release
, then copy it frombuild/release/
to thefiles/
folder. - Change the binary that is used from
counter
todoublecounter
inindex.js
. - Update the
createCells()
function.- Create a cell that uses the default lock with
address1
, and thedoublecounter
type script. - The cell should contain only the minimum capacity necessary to hold the cell data.
- The initial data values should be
42
and9000
. - The data field takes a hex string that must be prefixed with "0x". There should only be a single "0x" prefix even if there are two values included.
- Create a cell that uses the default lock with
- Update the
updateCells()
function to update the Double Counter cell that was created.- The first counter value should be increased by 1, the second value should increase by 2.
- The data field of the input cell and output cell contains a single hex string for all values, even if there are multiple values contained within. Your code must properly encode and decode this value.
Run your code by opening a terminal to the Lab-DoubleCounter-Exercise
folder and running node index.js
. If you get stuck you can find the solution in the Lab-DoubleCounter-Solution
folder.
Once your code successfully executes, the resulting transaction ID will be printed on the screen.