This guide will walk you through making your first contract call using the .
Mintbase offers a streamlined way to deploy your very own token smart contract equipped with all the necessary methods you might need. This can be achieved by making a call to our with the provided SDK method. For more documentation regarding how to call other methods check out the .
A prerequisite is to be able to have a wallet connection mechanism in your application. For that, you can check out a small guide on how to .
The SDK offers wrappers to make executing contract calls as easy as possible. These were specifically made to facilitate Mintbase market and token contract interaction.
In this case we are building a deployContract object with the specified fields that can be referenced
Note: this does not call the method
npm install @mintbase-js/sdk
import { useWallet } from '@mintbase-js/react';
import { deployContract } from '@mintbase-js/sdk';
// name is the name of the store/contract you need to pass from the parent component.
// symbol min characters is 1 and max 5 and need to be ALPHANUMERIC characters.
// owner must be a valid near account address.
interface DeployContractArgs {
name: string,
owner: string,
symbol: string,
}
const DeployContractComponent = ({ name, owner, symbol }: DeployContractArgs) => {
const { selector } = useWallet();
const handleDeployContract = async (): Promise<void> => {
const wallet = await selector.wallet();
const deployArgs = deployContract({
name: name,
ownerId: owner,
metadata: {
symbol: symbol
}
})
};
};
Step 3: Execute the contract call
The execute method takes any number of contract call objects and executes them using a provided wallet instance.
import { useState } from 'react';
import { useWallet } from '@mintbase-js/react';
import { execute, deployContract } from '@mintbase-js/sdk';
// name is the name of the store/contract you need to pass from the parent component.
// symbol min characters is 1 and max 5 and need to be ALPHANUMERIC characters.
// owner must be a valid near account address.
interface DeployContractArgs {
name: string,
owner: string,
symbol: string,
}
const DeployContractUI = ({ name, owner, symbol }:DeployContractArgs) => {
const { selector } = useWallet();
const handleDeployContract = async (): Promise<void> => {
const wallet = await selector.wallet();
await execute(
{wallet},
deployContract({
name: name,
ownerId: owner,
metadata: {
symbol: symbol
}
})
)
};
return (
<div>
<button onClick={handleDeployContract}>
DeployContract with name= {name} and owner= {owner}
</button>
</div>
);
};
```
Join Us and Build the Future
Congratulations! Now that you have deployed your very own token contract you can interact with it by calling any of the SDK methods!
.
Have feedback or perhaps need a hand? Reach out on our public developer support channel where we are happy to help!