0.2.8 • Published 10 months ago
@0xobelisk/sov-client v0.2.8
@0xobelisk/sov-client
This is an early experimental client used to communicate with the sequencer
Install (TODO: Need release to npmjs)
pnpm i @0xobelisk/sov-client
How to use
Account
import {Ed25519Keypair, getFullnodeUrl, SovereignClient} from "@0xobelisk/sov-client"
const main = async () => {
// import an Ed25519 account
const test_private_key: Uint8Array = new Uint8Array([
117, 251, 248, 217, 135, 70, 194, 105, 46, 80, 41, 66, 185, 56, 200, 35,
121, 253, 9, 234, 159, 91, 96, 212, 211, 158, 135, 225, 180, 36, 104,
253,
]);
const importKeypair = Ed25519Keypair.fromSecretKey(test_private_key, {
skipValidation: true,
});
// generate a new Ed25519 account
const keypair = new Ed25519Keypair();
console.log(keypair.getPublicKey());
console.log(keypair.getSecretKey());
console.log(keypair.toAddress());
console.log();
// generate a new Secp256k1 account
const ethKey = new Secp256k1Keypair();
console.log(ethKey.getPublicKey());
console.log(ethKey.getSecretKey());
};
main();
Submit Transaction
dev in localnet tips: don't forget start the local sov node.
import { Ed25519Keypair, Secp256k1Keypair, SovereignClient, getFullnodeUrl } from '@0xobelisk/sov-client';
const main = async () => {
const nodeApi = getFullnodeUrl('localnet');
const client = new SovereignClient(nodeApi);
// call bank.Freeze func
const callPayload: any = {
bank: {
Freeze: {
token_id:
'token_1rwrh8gn2py0dl4vv65twgctmlwck6esm2as9dftumcw89kqqn3nqrduss6',
},
},
};
// sign and submit tx
await client.signAndExecuteTransaction({
callPayload,
signer: keypair
})
};
main();
Call RPC
dev in localnet tips: don't forget start the local sov node.
import { Ed25519Keypair, Secp256k1Keypair, SovereignClient, getFullnodeUrl } from '@0xobelisk/sov-client';
const main = async () => {
const nodeApi = getFullnodeUrl('localnet');
const client = new SovereignClient(nodeApi);
const params = {
user_address:
'sov15vspj48hpttzyvxu8kzq5klhvaczcpyxn6z6k0hwpwtzs4a6wkvqwr57gc',
token_id:
'token_1zdwj8thgev2u3yyrrlekmvtsz4av4tp3m7dm5mx5peejnesga27ss0lusz',
};
const balance = await client.query('bank_balanceOf', params);
console.log(balance);
};
main();
Query Module State
dev in localnet tips: don't forget start the local sov node.
import { Ed25519Keypair, Secp256k1Keypair, SovereignClient, getFullnodeUrl } from '@0xobelisk/sov-client';
const main = async () => {
const nodeApi = getFullnodeUrl('localnet');
const client = new SovereignClient(nodeApi);
const state = await client.get('/xxxx', []);
console.log(state);
};
main();
How to build sov-client
Clone sov-clone repo
git clone https://github.com/Sovereign-Labs/sov-client
cd sov-client
compile sov-client
pnpm i
ts-node scripts/index.ts
0.1.0
10 months ago
0.2.1
10 months ago
0.1.2
10 months ago
0.2.0
10 months ago
0.1.1
10 months ago
0.2.7
10 months ago
0.1.8
10 months ago
0.0.9
10 months ago
0.2.6
10 months ago
0.1.7
10 months ago
0.0.8
10 months ago
0.2.8
10 months ago
0.1.9
10 months ago
0.2.3
10 months ago
0.1.4
10 months ago
0.2.2
10 months ago
0.2.5
10 months ago
0.0.7
10 months ago
0.2.4
10 months ago
0.1.5
10 months ago
0.0.6
10 months ago
0.0.5
10 months ago
0.0.4
10 months ago
0.0.3
10 months ago
0.0.2
10 months ago
0.0.1
10 months ago