Skip to main content
AdvancedEst10 minsdk-core15Reference

Deploy a multisig contract

The sdk contains components to interact with the Multisig Contract. We can deploy a multisig smart contract, add members, propose and execute actions and query the contract. The same as the other components, to interact with a multisig smart contract we can use either the MultisigController or the MultisigTransactionsFactory.

These operations can be performed using both the controller and the factory. For a complete list of supported methods, please refer to the autogenerated documentation:

Deploying a Multisig Smart Contract using the controller

import * as fs from 'fs';
import * as path from 'path';
import { Abi, Account, Address, DevnetEntrypoint } from '@multiversx/sdk-core';

{
const abiJson = fs.readFileSync('src/testdata/multisig-full.abi.json', { encoding: 'utf8' });
const abi = Abi.create(JSON.parse(abiJson));
const bytecode = new Uint8Array(fs.readFileSync('src/testdata/multisig-full.wasm'));

// create the entrypoint and the multisig controller
const entrypoint = new DevnetEntrypoint();
const controller = entrypoint.createMultisigController(abi);

const filePath = path.join("../src", "testdata", "testwallets", "alice.pem");
const alice = await Account.newFromPem(filePath);

// fetch the nonce of the network
alice.nonce = await entrypoint.recallAccountNonce(alice.address);

const transaction = await controller.createTransactionForDeploy(alice, alice.getNonceThenIncrement(), {
quorum: 2,
board: [
alice.address,
Address.newFromBech32("erd1spyavw0956vq68xj8y4tenjpq2wd5a9p2c6j8gsz7ztyrnpxrruqzu66jx"),
],
bytecode,
gasLimit: 100000000n,
});

// sending the transaction
const txHash = await entrypoint.sendTransaction(transaction);

// wait for transaction completion, extract multisig contract's address
const outcome = await controller.awaitCompletedDeploy(txHash);

const contractAddress = outcome.contracts[0].address;
}

Deploying a Multisig Smart Contract using the factory

import * as fs from 'fs';
import * as path from 'path';
import { Abi, Account, Address, DevnetEntrypoint } from '@multiversx/sdk-core';

{
const abiJson = fs.readFileSync('src/testdata/multisig-full.abi.json', { encoding: 'utf8' });
const abi = Abi.create(JSON.parse(abiJson));
const bytecode = new Uint8Array(fs.readFileSync('src/testdata/multisig-full.wasm'));

// create the entrypoint and the multisig factory
const entrypoint = new DevnetEntrypoint();
const factory = entrypoint.createMultisigTransactionsFactory(abi);

const filePath = path.join("../src", "testdata", "testwallets", "alice.pem");
const alice = await Account.newFromPem(filePath);

// fetch the nonce of the network
alice.nonce = await entrypoint.recallAccountNonce(alice.address);

const transaction = await factory.createTransactionForDeploy(alice.address, {
quorum: 2,
board: [
alice.address,
Address.newFromBech32("erd1spyavw0956vq68xj8y4tenjpq2wd5a9p2c6j8gsz7ztyrnpxrruqzu66jx"),
],
bytecode,
gasLimit: 100000000n,
});

transaction.nonce = alice.getNonceThenIncrement();
transaction.signature = await alice.signTransaction(transaction);
// sending the transaction
const txHash = await entrypoint.sendTransaction(transaction);
}