@scintilla-network/sdk
v3.0.0
Published
A TypeScript SDK for Node.js and Web Browsers
Maintainers
Readme
@scintilla-network/sdk
The @scintilla-network/sdk provides a comprehensive suite of TypeScript primitives and utilities designed for building and interacting with the Scintilla blockchain. This SDK simplifies the development process by offering well-defined structures for assets, governance, transactions, and more, alongside essential utilities for hashing and variable-length integer handling.
Installation
To install the SDK in your project, run:
npm install @scintilla-network/sdkPrimitives
The SDK includes a variety of primitives, each tailored for specific use cases within the Scintilla ecosystem:
- Asset - An asset is a specific asset in the Scintilla network.
- Authorization - An authorization is a message that is used to authorize a specific action.
- BigDecimal - A big decimal is a decimal number that is used to represent a large number.
ClusterBlock - A cluster block is a block representation in a specific cluster.
DriveData - A drive data is a data that is stored in drive.
GovernanceProposal - A governance proposal is a proposal to the DAO.
GovernanceVote - A governance vote is a vote on a governance proposal.
HashProof - A hash proof is a POW block in a cluster
Identity - An identity is a unique entity with a moniker, address, and associated records.
Instruction - An instruction is a message that is used to perform a specific action.
Messages - Messages are the fundamental units of communication in the Scintilla network.
QuorumDecision - A quorum decision is a decision made by a quorum.
QuorumDecisionVote - A quorum decision vote is a vote on a quorum decision.
RelayBlock - A relay block is a specific block that happen between relayers.
Transaction - A transaction is a message that is used to perform a specific action.
Transfer - A transfer is a message that is used to transfer assets.
Voucher - A digital voucher for transferring assets.
Transition - A transition is a message that is used to transition the state of the system.
Misc Primitives
- Peer - A peer is a part of the network.
Message
The SDK also includes primitives for message handling:
Utilities
For technical operations, the SDK provides utility functions and data structures:
- Hash (sha256)
- VarInt Encoding/Decoding
- serialize
- fromString - Serialize a string to a byte array.
- fromVarInt - Serialize a number to a byte array.
- fromVarBigInt - Serialize a big integer to a byte array.
- fromObject - Serialize an object to a byte array.
- fromArray - Serialize an array to a byte array.
- deserialize
- toVarInt - Deserialize a byte array to a number.
- toVarBigInt - Deserialize a byte array to a big integer.
- toObject - Deserialize a byte array to an object.
- toArray - Deserialize a byte array to an array.
- toString - Deserialize a byte array to a string.
- kindToConstructor
Data Structures
Some technical utilities are designed for specific data handling and management scenarios:
Trees
MerkleTree and PatriciaTree are exported from @scintilla-network/trees for convenience.
import { Trees } from '@scintilla-network/sdk';
const merkleTree = new Trees.MerkleTree();
const patriciaTree = new Trees.PatriciaTree();
console.log(Trees.HASH_ALGORITHMS);Merkle Tree are used to generate merkle root and proofs for a given data (i.e: HashProof, ClusterBlock, RelayBlock, etc.).
Network kind
Each packet starts with a kind:
UNKNOWN = 0,
PEER_INFO = 1,
REQUEST = 2,
RESPONSE = 3,
ACKHANDSHAKE = 4,
EPOCHBLOCK = 5,
CLUSTERBLOCK = 6,
HASHPROOF = 7,
TRANSACTION = 8,
TRANSITION = 9,
TRANSFER = 10,
STATEMENT = 11,
HANDSHAKE = 12,
QUORUMDECISION = 13,
QUORUMDECISIONVOTE = 14,
RELAYBLOCK = 15,
VOUCHER = 16,
ASSET = 17,
IDENTITY = 18,
GOVERNANCEPROPOSAL = 19,
GOVERNANCEVOTE = 20,
INSTRUCTION = 21,
RAW = 22,
PACKEDOBJECT = 23,
PACKEDARRAY = 24,These data structures are exported separately to emphasize their utility nature and potential broader applicability outside the direct blockchain interaction scenarios.
Usage
To use a primitive or utility from the SDK, import it into your TypeScript file as follows:
import { Asset, Transfer, sha256 } from '@scintilla-network/sdk';
// Example usage
const asset = new Asset({/* initial properties */});
const transfer = new Transfer({/* initial properties */});
const hash = sha256('your data here');Refer to the individual documentation for each primitive and utility for detailed usage instructions.
Browser
<script type="module">
import {Asset} from "@scintilla-network/sdk";
console.log(new Asset('test'));
</script>Related Packages
Contributing
We welcome contributions to the @scintilla-network/sdk! Please read our Contributing Guide for details on our code of conduct, and the process for submitting pull requests to us.
License
This project is licensed under the MIT License - see the LICENSE file for details.
