These are some utility functions used throughout the guide. You may want to include them in your project.
import { createVertexClient } from '@vertex-protocol/client';
import { toPrintableObject } from '@vertex-protocol/utils';
import { createPublicClient, createWalletClient, http } from 'viem';
import { privateKeyToAccount } from 'viem/accounts';
import { arbitrumSepolia } from 'viem/chains';
/**
* Creates a Vertex client for example scripts
*/
export function getVertexClient() {
const walletClient = createWalletClient({
account: privateKeyToAccount('0x...'),
chain: arbitrumSepolia,
transport: http(),
});
const publicClient = createPublicClient({
chain: arbitrumSepolia,
transport: http(),
});
return createVertexClient('arbitrumTestnet', {
walletClient,
publicClient,
});
}
/**
* Util for pretty printing JSON
*/
export function prettyPrintJson(label: string, json: unknown) {
console.log(label);
console.log(JSON.stringify(toPrintableObject(json), null, 2));
}