Skip to content
API
Transactions
Custom transactions

Creating custom transactions

Throughout our service, we've added multiple methods for you to manage assets for the Profiles you've created. However, as your game and asset contract complexity grows, a more interesting way of handling complicated transactions is by directly communicating with an asset contract.

There's a limit of 9 interactions per transaction to prevent potential security vulnerabilities. Making calls to external contracts within loops can risk Denial of Service (DoS) or transaction failures if they consume more gas than a block's limit.

You can simply do this by creating a transaction that interacts with one or more contracts in one go by padding an interactions array. This would look something like the snippet below. Keep in mind that everything you see below is completely contextual based on the contracts you're calling and the functions that are available on said contract.

const transaction = await beam.transactions.createTransaction("profile-id", {
  interactions: [
    {
      contract: "0x9eeaecbe2884aa7e82f450e3fc174f30fc2a8de3", // 👈 the asset contract you're calling
      functionName: "_mint", // 👈 functions are defined in the asset contract you're calling
      functionArgs: ["0x000..", "arg-2", "arg-3", "arg-4"], // 👈 this completely depends on the function you're calling
    },
  ],
});
 
// {
//   "status": "success",
//   "transactionHash": '0x71f3f259568e9875c41a4350a3912a3a7650d9321ccd1d57641241128b4e504f',
//   "explorerUrl": "https://subnets.avax.network/beam/0x71f3f259568e9875c41a4350a3912a3a7650d9321ccd1d57641241128b4e504f"
// }