Getting started
Quick start
Every snippet below runs against the real SDK. Pick the path that matches where your code executes.
Try it in the playgroundBuild a standardized payload
TypeScript
import { HiveClient } from "hivexph-sdk";
const hive = new HiveClient();
const operation = hive.builder.buildOperation({
username: "alice",
id: "my-application",
action: "claim",
metadata: { rewardId: "123" },
authority: "posting",
});Browser: sign with Hive Keychain
TypeScript
if (!hive.keychain.isAvailable()) {
throw new Error("Install the Hive Keychain extension");
}
const signIn = await hive.keychain.requestSignIn({
username: "alice",
message: "Sign in to my-application: nonce-123456",
});
const result = await hive.keychain.customJson({
username: "alice",
id: "my-application",
action: "claim",
metadata: { rewardId: "123" },
authority: "posting",
message: "Claim reward",
});
console.log(result.transactionId);Note
A Keychain result means the transaction was submitted, not that it was included in a block. Confirm inclusion with the transaction reader or a block stream.
Backend: sign with an account alias
server.ts
const hive = new HiveClient({
accounts: {
treasury: { accountEnv: "HIVE_TREASURY_ACCOUNT", keyEnv: "HIVE_TREASURY_ACTIVE_KEY" },
},
});
const result = await hive.issuer.token.issue({
from: hive.accounts.treasury,
symbol: "MYTOKEN",
account: "bob",
quantity: "10",
});Security
The alias resolves to a real account and key only at call time, inside the server runtime.
Read the transaction back
TypeScript
const read = await hive.reader.transaction({ transactionId: result.transactionId! });
console.log(read.customJson);