Skip to main content

Using the commandBuilder

You may prefer to not generate JavaScript code for your contracts or use templates. In that case, you can use the commandBuilder function to build a command and submit the transaction yourself:

import { Pact } from '@kadena/client';
 
const client = createClient(
  'https://api.testnet.chainweb.com/chainweb/0.0/testnet04/chain/8/pact',
);
 
const unsignedTransaction = Pact.builder
  .execution('(format "Hello {}!" [(read-msg "person")])')
  // add signer(s) if its required
  .addSigner('your-pubkey')
  // set chian id and sender
  .setMeta({ chainId: '8', sender: 'your-pubkey' })
  // set networkId
  .setNetworkId('mainnet01')
  // create transaction with hash
  .createTransaction();
 
// Send it or local it
client.local(unsignedTransaction);
client.submit(unsignedTransaction);
import { Pact } from '@kadena/client';
 
const client = createClient(
  'https://api.testnet.chainweb.com/chainweb/0.0/testnet04/chain/8/pact',
);
 
const unsignedTransaction = Pact.builder
  .execution('(format "Hello {}!" [(read-msg "person")])')
  // add signer(s) if its required
  .addSigner('your-pubkey')
  // set chian id and sender
  .setMeta({ chainId: '8', sender: 'your-pubkey' })
  // set networkId
  .setNetworkId('mainnet01')
  // create transaction with hash
  .createTransaction();
 
// Send it or local it
client.local(unsignedTransaction);
client.submit(unsignedTransaction);

Receive important developer updates