Hi there, currently using the moralis SDK for unity and I can link my metamask wallets on Polygon test network. I was wondering how to call a mint function from a contract I have already deployed.
So the user opens a chest, calls the smart contracts mint function and the transaction process starts.
Thanks.
I havenβt tried it yet, but I guess once you have connected your unity to Moralis Web3 SDK, you should be able to call the smart contract functions to mint you NFT.
like @johnversus said, Thanks btw john
You basically have to call a smart contract function for minting, you can take a looka t the boilerplate
Take a look at calling smart contract functions with gas
And this should be the typically code snippet that may need some tweaks and it should resemble
public string ABI;
public long value = 70000000000000000;
public async void MintNFT()
{
MoralisUser user = await MoralisInterface.GetUserAsync();
string addr = user.authData["moralisEth"]["id"].ToString();
MoralisInterface.InsertContractInstance("LOL", ABI, "eth", "0xECEB6268F75174887a233112fc8bB9F8149CE45D");
// Set gas estimate
HexBigInteger gas = new HexBigInteger(80000);
string senderAddress = addr;
object[] pars = {1};
string resp = await MoralisInterface.SendEvmTransactionAsync("LOL", "eth", "mint", senderAddress, gas, new HexBigInteger(value), pars);
print(resp);
}
So this should allow you to call the mint function from the abi passed from the unity inspector
and to give more insights, this code was made to mint from
https://etherscan.io/address/0xECEB6268F75174887a233112fc8bB9F8149CE45D#code
with the abi provided there
Thanks for the info, will test it!