Get started with godprotocol
godprotocol
npm install godprotocol --save
Create an Account
Accounts comes with their own VM, thereby providing concurrency on processes being executed.
import { start } from "godprotocol";
// Create an initial account
let initiator = start(`public_key`, { private: true | false });
// if private is set to `true`, communication to the account instance must be validated by sigining with the private key.
// N.B your keypairs are generated offline.
Parameters | Type | Description |
---|---|---|
name | string | Account names can be any valid variable string. Such as a Public Key |
private | object:boolean | default false, if set to true, then any payloads sent to the account must be signed using the private key belonging to the account name |
Load Instructions
The load method is the second in the pipeline, It is used to set your programs into the network web, where its data can continue to be accessed, and subsequent calls can be made on the loaded program.
Usage
initiator.load(
{
instructions: ["link Account/initiator/Datatypes/Number", "write 7", "pop"],
account: `public_key`,
},
cb
);
Type method
Parameters | Type | Destructure | Description |
---|---|---|---|
program | object | instructions | An array of opcode-operands generated by the Loader Sequence |
account | Account instance to load and execute the program in. | ||
cb | function |
Run Program
The run is technically the second in the pipeline.
Usage
initiator.run(
{
physical_address: "Account/initiator/Datatypes/Number", // This points to a chain
query: { blocks: 0 }, // Basically saying, index 0 block in physical_address chain, run again its instructions.
account: `public_key`,
},
cb
);
// N.B If query is missing, then VM starts execution from the block-index-0
Type method
Parameters | Type | Destructure | Description |
---|---|---|---|
payload | object | physical_address | Physical Addresses are logical namespace locations of tokens. They are derived from the high-level representation of the program's instructions. |
object | query | A valid blockweb explorer query, you can read the explorer documentation here | |
string | account | Account instance to execute the instructions in. | |
cb | function |