Blockchain NFTs operations
Create sub-account :
async createAccount(createSubAccount: CreateSubAccount) {
try {
let rpcUrl;
let networkId;
if (createSubAccount.chain === "testnet") {
rpcUrl = "https://rpc.testnet.near.org";
networkId = "testnet";
} else if (createSubAccount.chain === "mainnet") {
rpcUrl = "https://rpc.mainnet.near.org";
networkId = "mainnet";
} else {
throw new Error("Chain parameter is not defined");
}
this.addKeyPairToKeyStore(
createSubAccount.account_id,
createSubAccount.chain
);
this.connectionConfig = {
networkId: networkId,
keyStore: this.myKeyStore,
nodeUrl: "https://rpc.testnet.near.org",
walletUrl: "",
helperUrl: "",
explorerUrl: "",
};
const near = await nearAPI.connect(this.connectionConfig);
const account = await near.account(createSubAccount.account_id);
const publickey = this.keyPair.getPublicKey().toString();
const PK = publickey.replace("ed25519:", "");
const amount = new BN(createSubAccount.amount);
const response = account.createAccount(
createSubAccount.newAccountId,
PK,
amount.mul(new BN("1000000000000000000000000"))
);
return JSON.stringify( (await response).transaction.hash );
} catch (err) {
console.log(err);
}
}Deploy smart contract with default Metadata :
Deploy smart contract with custom Metadata :
Mint NFT :
Last updated
Was this helpful?
