Wharfkit provides a lot of the functionality that Ultra needs but we want to simplify our transactions where possible.
This library aims to provide similar functionality to eosjs
without the added complexity of using @wharfkit/antelope
directly.
Features
npm i @ultraos/ultra-signer-lib
import { API } from '@ultraos/ultra-signer-lib';
// Compromised key, do not use for production.
const publicKey = 'EOS8NcQNcaR1eRyLPnCBoq6KRUGYHW5CDBVTWgLBii3Vas4dXTgMf';
const privateKey = '5JNcnnozrvvgmqP7oigzD9UuNn9JLCtmL69qPTmvz7cMAtBTRZZ';
const api = new API(TEST_ENDPOINT, { signingMode: 'PRIVATE_KEY', privateKeys: [privateKey] });
// This is asynchronous, wrap it in an async function, or use then
const result = await api.transact([
{
account: 'eosio.token',
name: 'transfer',
authorization: [{ actor: from, permission: 'active' }],
data: {
from: 'alice',
to: 'bob',
quantity: '0.00000000 UOS',
memo: 'hi',
},
},
]);
if (result.status) {
console.log(`Transaction Successful!`);
console.log(result.data);
} else {
console.log(`Transaction Failed!`);
console.log(result.data);
}
import { Signer } from '@ultraos/ultra-signer-lib';
// Note that these keys are exposed and should not be used at all or in production
const publicKey = 'EOS8NcQNcaR1eRyLPnCBoq6KRUGYHW5CDBVTWgLBii3Vas4dXTgMf';
const privateKey = '5JNcnnozrvvgmqP7oigzD9UuNn9JLCtmL69qPTmvz7cMAtBTRZZ';
const originalMessage = 'hello world!';
const signature = Signer.sign(originalMessage, privateKey);
console.log(Signer.verify(signature, originalMessage, publicKey));
import { API } from '@ultraos/ultra-signer-lib';
const api = new API(TEST_ENDPOINT, { signingMode: 'KEOSD', keosdEndpoint: KEOSD_ENDPOINT });
const result = await api.transact([
{
account: 'eosio.token',
name: 'transfer',
authorization: [{ actor: from, permission: 'active' }],
data: { from, to, quantity, memo },
},
]);
KMS can be used to create a shared private key that signs transactions through Google APIs.
Creating a key should be -> HSM
, Asymmetric Sign
, Elliptic Curve secp256k1 with SHA256 Digest
import { API, SignerKMS } from '@ultraos/ultra-signer-lib';
const credentials = {
project_id: 'some google project identifier',
private_key: 'the private key you get from the .json file when you create a kms key',
client_email: 'service account email',
client_id: 'service account client id',
};
const keypath = {
project: 'some google project identifier',
location: 'global',
keyRing: 'key ring name',
cryptoKey: 'key name',
cryptoKeyVersion: '1',
};
const kmsService = new SignerKMS(credentials, keypath);
const api = new API(TEST_ENDPOINT, { signingMode: 'KMS', KMS: kmsService });
import { API, SignerKMS } from '@ultraos/ultra-signer-lib';
const api = new API(TEST_ENDPOINT, { signingMode: 'KMS', KMS: kmsService });
const result = await api.transact([
{
account: 'eosio.token',
name: 'transfer',
authorization: [{ actor: from, permission: 'active' }],
data: { from, to, quantity, memo },
},
]);
import { Signer, SignerKMS } from '@ultraos/ultra-signer-lib';
const originalMessage = 'hello world!';
const signature = Signer.sign(originalMessage, kmsService);
console.log(Signer.verify(signature, originalMessage, kmsService));
Any additional documentation for individual functions and utilities can be found here:
To install dependencies:
npm i
npm run test
npm run build
Generated using TypeDoc