Skip to content

Latest commit

 

History

History

contract-deployer

Contract Deployer

cover_image

A Simple example of a Contract Deployer built on Next.js 14

Demo Deploy

Tooling:

Use Case Tools Framework

Author:

Author Organization

Project Walkthrough

This is a simple contract deployer example built on top of mintbase nextjs starter.

To initiate the contract deployment process, the user is required to connect their wallet. Following the wallet connection, the user can proceed to select the desired contract name and its corresponding symbol. It's important to note that the deployment fee for a contract is 3.7 NEAR.

NOTE: As a standard on Mintbase as we use the latest versions of Next.js we recommend using pnpm, but the package manager is up to your personal choice.

Run the project

pnpm i

pnpm run dev

Deploy Contract

Step 1: check if the contract name already exists

Using @mintbase-js/data checkStoreName method we can check if the store already exists.

const { data: checkStore } = await checkStoreName(data.name);

if (checkStore?.nft_contracts.length === 0) {
  (...)
}

Step 2: if contract name doesn't exist execute the deploy contract action with the instantiated wallet

Create deploy contract args using mintbase-js/sdk deployContract method.

const deployArgs = deployContract({
  name: data.name,
  ownerId: activeAccountId,
  factoryContractId: MINTBASE_CONTRACTS.testnet,
  metadata: {
    symbol: data.symbol,
  },
});

We can then execute the deploy contract

  await execute({ wallet }, deployArgs);

Presently, this template exclusively functions within the testnet environment. To transition to a different network, it is imperative to modify the configuration settings located in the contract-deployer/src/config/setup.ts file and every 'testnet' instance.

Get in touch

detail_image