import { Identities, Managers, Transactions, Utils } from "@arkecosystem/crypto";
import { ProtokolConnection } from "@protokol/client";
import { Builders, Transactions as GuardianTransactions } from "@protokol/guardian-crypto";
export const GroupPermissions = async (): Promise<void> => {
// Configure our API client
const client = new ProtokolConnection("http://localhost:4003/api");
const passphrase = "clay harbor enemy utility margin pretty hub comic piece aerobic umbrella acquire";
// Configure manager and register transaction type
const configs = await client.api("node").crypto();
} = await client.get("blockchain");
Managers.configManager.setConfig({ ...configs.body.data } as any);
Managers.configManager.setHeight(height);
Transactions.TransactionRegistry.registerTransactionType(GuardianTransactions.GuardianGroupPermissionsTransaction);
// Step 1: Retrieve the nonce of the sender wallet
const senderWallet = await client.api("wallets").get(Identities.Address.fromPassphrase(passphrase));
const senderNonce = Utils.BigNumber.make(senderWallet.body.data.nonce).plus(1);
// Step 2: Create the transaction
const transaction = new Builders.GuardianGroupPermissionsBuilder()
.GuardianGroupPermissions({
name: "Test Guardian Permission Group",
allow: [{ transactionType: 1, transactionTypeGroup: 1 }],
deny: [{ transactionType: 2, transactionTypeGroup: 1 }],
.nonce(senderNonce.toFixed())
// Step 3: Broadcast the transaction
const broadcastResponse = await client.api("transactions").create({ transactions: [transaction.build().toJson()] });
// Step 4: Log the response
console.log(JSON.stringify(broadcastResponse.body, null, 4));
.then(() => process.exit(0))