Readme

Union TypeScript SDK

Example Usage

import { http } from "viem"; import { privateKeyToAccount } from "viem/accounts"; import { createUnionClient, hexStringToUint8Array } from "@union/client"; const PRIVATE_KEY = process.env.PRIVATE_KEY; const account = privateKeyToAccount(`0x${PRIVATE_KEY}`); const client = createUnionClient({ account, chainId: "80084", transport: http("https://bartio.rpc.berachain.com"), }); const transfer = await client.transferAsset({ amount: 1n, autoApprove: true, destinationChainId: "stride-internal-1", recipient: "stride14qemq0vw6y3gc3u3e0aty2e764u4gs5l66hpe3", denomAddress: "0x0E4aaF1351de4c0264C5c7056Ef3777b41BD8e03", // HONEY }); if (transfer.isErr()) { console.error("Transfer failed", transfer.error); } console.info("Transfer successful", transfer.value);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import { createUnionClient } from "jsr:@union/client";
import { http } from "npm:viem";
import { privateKeyToAccount } from "npm:viem/accounts";
const PRIVATE_KEY = "";
const account = privateKeyToAccount(`0x${PRIVATE_KEY}`);
const client = createUnionClient({
account,
chainId: "80084",
transport: http("https://bartio.rpc.berachain.com"),
});
const transfer = await client.transferAsset({
amount: 1n,
autoApprove: true,
destinationChainId: "stride-internal-1",
recipient: "stride14qemq0vw6y3gc3u3e0aty2e764u4gs5l66hpe3",
denomAddress: "0x0E4aaF1351de4c0264C5c7056Ef3777b41BD8e03", // HONEY
});
if (transfer.isErr()) {
console.error("Transfer failed", transfer.error);
}
console.info("Transfer successful", transfer.value);
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
September 3, 2024