Skip to content

Commit 55b0b38

Browse files
authored
add new XTZ staking routes (#132)
1 parent 0fa9f46 commit 55b0b38

File tree

4 files changed

+45430
-36166
lines changed

4 files changed

+45430
-36166
lines changed

examples/xtz.ts

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import { Kiln } from "../src/kiln";
2+
import fs from "node:fs";
3+
import 'dotenv/config'
4+
import type { FireblocksIntegration } from "../src/fireblocks.ts";
5+
6+
7+
const apiSecret = fs.readFileSync(`${__dirname}/fireblocks_secret.key`, 'utf8');
8+
9+
const k = new Kiln({
10+
baseUrl: process.env.KILN_API_URL as string,
11+
apiToken: process.env.KILN_API_KEY as string,
12+
});
13+
14+
const vault: FireblocksIntegration = {
15+
provider: 'fireblocks',
16+
fireblocksApiKey: process.env.FIREBLOCKS_API_KEY as string,
17+
fireblocksSecretKey: apiSecret,
18+
vaultId: 14
19+
};
20+
21+
try {
22+
console.log('crafting...');
23+
const tx = await k.client.POST(
24+
'/v1/xtz/transaction/delegate',
25+
{
26+
body: {
27+
account_id: 'd3f1b917-72b1-4982-a4dd-93fce579a708',
28+
wallet: 'tz1WmYmabzcmguEiJzZyL4rKDhBdgfa1bLod',
29+
baker_address: 'tz1YgDUQV2eXm8pUWNz3S5aWP86iFzNp4jnD'
30+
}
31+
}
32+
);
33+
console.log('signing...');
34+
if(!tx.data) throw new Error('No data in response');
35+
const signResponse = await k.fireblocks.signXtzTx(vault, tx.data.data, "XTZ_TEST");
36+
if(!signResponse.signed_tx?.data.signed_tx_serialized) throw new Error('No signed_tx in response');
37+
console.log('broadcasting...');
38+
const broadcastedTx = await k.client.POST("/v1/xtz/transaction/broadcast", {
39+
body: {
40+
tx_serialized: signResponse.signed_tx.data.signed_tx_serialized
41+
}
42+
});
43+
console.log(broadcastedTx);
44+
45+
} catch (err) {
46+
console.log(err);
47+
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@kilnfi/sdk",
3-
"version": "3.0.8",
3+
"version": "3.1.0",
44
"autor": "Kiln <[email protected]> (https://kiln.fi)",
55
"license": "BUSL-1.1",
66
"description": "JavaScript sdk for Kiln API",

0 commit comments

Comments
 (0)