Ask or search…
K
Links

deployContract

Deploys a new contract from a given factoryContractId
As with all new SDK api methods, this call should be wrapped in execute and passed a signing method

deployContract(args: DeployContractArgs): NearContractCall

deployContract takes a single argument of type DeployContractArgs
export type DeployContractArgs = {
//the contract factory used to deploy the contract
//if not provided defaults to the mintbase testnet contract factory: 'mintspace2.testnet'
factoryContractId?: string;
//name for the contract, this should be unique within the factory
name: string;
//wallet id of the intended owner
ownerId: string;
metadata: {
symbol: string;
//if nothing is provided will default to the mb default logo
icon?: string;
//will default to null
baseUri?: string;
//will default to null
reference?: string;
//will default to null
referenceHash?: string;
};
};

React example

Example usage of deployContract method in a hypothetical React component:
DeployContractComponent.ts
1
import { useState } from 'react';
2
import { useWallet } from '@mintbase-js/react';
3
import { execute, deployContract , DeployContractArgs } from '@mintbase-js/sdk';
4
5
6
export const DeployContractComponent = ({ name, owner, contractId, symbol }:DeployContractArgs):JSX.Element => {
7
8
const { selector } = useWallet();
9
10
const handleDeployContract = async (): Promise<void> => {
11
const wallet = await selector.wallet();
12
13
await execute(
14
//because no contract factory id is provided it defaults to 'mintspace2.testnet'
15
{wallet},
16
deployContract({
17
name: name,
18
ownerId: owner,
19
metadata: {
20
symbol: symbol
21
}
22
})
23
)
24
}
25
26
return (
27
<div>
28
<button onClick={() => handleDeployContract()}>
29
DeployContract with name= {name} and owner= {owner}
30
</button>
31
</div>
32
);
33
};