Beekeeper

Wax signer library extending transaction signing possibilities by a safe wallet - Beekeeper

Install package

View Beekeeper signer package on npmjs 🡭
https://npmjs.com/package/@hiveio/wax-signers-beekeeper

pnpm add @hiveio/wax-signers-beekeeper
pip install beekeepy --index-url https://gitlab.syncad.com/api/v4/projects/434/packages/pypi/simple

View Beekeeper signer crate on crates.io
https://crates.io/crates/hiveio-wax-signers-beekeeper

cargo add hiveio-wax-signers-beekeeper

The crate is imported as wax_signers_beekeeper in code, e.g.: use wax_signers_beekeeper::BeekeeperSignatureProvider;

Usage

import { createHiveChain } from "@hiveio/wax";
import BeekeeperProvider from "@hiveio/wax-signers-beekeeper";

const chain = await createHiveChain();

const provider = BeekeeperProvider.for(myWallet, "myaccount", "active", chain);

// Create a transaction using the Wax Hive chain instance
const tx = await chain.createTransaction();

// Perform some operations, e.g. push the vote operation:
tx.pushOperation({
  vote_operation: {
    voter: "alice",
    author: "bob",
    permlink: "example-post",
    weight: 10000
  }
});

// Wait for the keychain to sign the transaction
 await provider.signTransaction(tx);

// broadcast the transaction
await chain.broadcast(tx);
from __future__ import annotations

import asyncio

from beekeepy import AsyncBeekeeper
from wax import create_hive_chain
from wax.proto.operations import vote


async def main() -> None:
    # Initialize hive chain interface
    chain = create_hive_chain()

    # Generate one pair of keys
    key = chain.get_private_key_from_password("account_name", role="active", password="password")
    public_key = key.associated_public_key
    private_key = key.wif_private_key

    tx = await chain.create_transaction()
    tx.push_operation(vote(voter="alice", author="bob", permlink="example-post", weight=10000))

    async with await AsyncBeekeeper.factory() as beekeeper:
        async with await beekeeper.create_session() as session:
            existing_wallets = [w.name for w in await session.wallets_created]

            if "wallet_name" in existing_wallets:
                wallet = await session.open_wallet(name="wallet_name")
                unlocked = await wallet.unlock("password_to_wallet")
            else:
                unlocked = await session.create_wallet(name="wallet_name", password="password_to_wallet")

            async with unlocked:
                await unlocked.import_key(private_key=private_key)
                # Wait for the beekeeper to sign the transaction
                await tx.sign(unlocked, public_key)

                # broadcast the transaction
                # await chain.broadcast(transaction=tx)


asyncio.run(main())
use beekeeper::api::BeekeeperApi;
use beekeeper::options::BeekeeperOptions;
use wax::prelude::*;
use wax_signers_beekeeper::BeekeeperSignatureProvider;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let chain = create_hive_chain(None)?;

    // Open an in-memory Beekeeper wallet and import your private key
    let api = BeekeeperApi::new(BeekeeperOptions::new("my-storage").in_memory(true));
    let session = api.create_session()?;
    let mut wallet = session.create_wallet("my-wallet", "my-password")?.wallet;
    let public_key = wallet.import_key("your-private-key")?;

    // Wrap the unlocked wallet in a Wax signature provider
    let provider = BeekeeperSignatureProvider::new(wallet);

    // Create a transaction using the Wax Hive chain instance
    let mut tx = chain.create_transaction(None).await?;

    // Perform some operations, e.g. push the vote operation:
    tx.push_operation(chain.create_operation(Value::VoteOperation(Vote {
        voter: "alice".into(),
        author: "bob".into(),
        permlink: "example-post".into(),
        weight: 10000,
    })));

    // Sign the transaction
    tx.sign(&provider, &public_key)?;

    // Broadcast the transaction
    chain.broadcast(&tx).await?;

    Ok(())
}