Skip to main content

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.
ParametersTypeDescription
namestringAccount names can be any valid variable string. Such as a Public Key
privateobject:booleandefault 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

ParametersTypeDestructureDescription
programobjectinstructionsAn array of opcode-operands generated by the Loader Sequence
accountAccount instance to load and execute the program in.
cbfunction

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

ParametersTypeDestructureDescription
payloadobjectphysical_addressPhysical Addresses are logical namespace locations of tokens. They are derived from the high-level representation of the program's instructions.
objectqueryA valid blockweb explorer query, you can read the explorer documentation here
stringaccountAccount instance to execute the instructions in.
cbfunction