credits-lib-js
v0.0.1
Published
Library for client-side interactions with a Credits network.
Downloads
4
Readme
Credits.js
Library for client-side interactions with a Credits network.
Look in test/test.js for some examples of how to use the featureset.
Examples:
const c = require('credits');
// Create an SK and Address
var sk = new c.key.ED25519SigningKey('19f81562ebb520afbc20a9a2fac73db93bd3d0ed1d9292fc8f7fc52826648ea6');
var new_address = address.address(sk.verifying_key());
// Create a Transform.
var manifest = {
"fqdn": 'credits.balance.transform.BalanceTransferTransform',
"address_from": 'String',
"address_to": 'String',
"amount": 'Integer'
};
var payload = {
"address_from": "test_address_1",
"address_to": "test_address_2",
"amount": 500
}
var transform = new c.transform.Transform(
manifest,
payload
);
// Create a Proof
challenge = transform.challenge();
proof = new c.proofs.SingleKeyProof(
address,
0, // nonce
challenge
);
proof.sign(sk);
// Create a Transaction
transaction = new c.tranaction.Transaction(
transform,
{
[address]: proof
}
);
// Marshall works bit-for-bit (maybe!) for Transactions.
console.log(transaction.marshall());