InsertContractInstance and SendEvmTransactionAsync methods are working, donāt mind the warnings. I donāt know why they put Obsolete there in the last version for no reason.
Here is the function that I am using with no issue. Hope it helps you.
// MoralisInterface.InsertContractInstance("transfer", ABI, chainId, erc20ContractAddress);
public async void SendERC20()
{
Function f = MoralisInterface.EvmContractFunctionInstance("transfer", chainID, "transfer");
HexBigInteger gas = new HexBigInteger(80000);
string result = await f.SendTransactionAsync(fromAddress, gas, new HexBigInteger("0x0"), receiver, amount);
Debug.Log(result);
}
Basically we are trying to standardize how Web3 works in both WebGL and non-WebGL We are discussing about the merits of keeping the Contract related methods (not the two SendTransaction methods) and implementing equivalents for WebGL.
Hi there,
Could you suggest how i can make an āauto create walletā function ?
That would generate a wallet within the game ?
I saw a few solutions out there, but wanting to know if there is a moralis solution
thanks !
I do not know if you have solved this problem, but I solved it this way:
- Find 2 of your WebSockets and open them (you can use notepad)
- Copy the entire text from any WebSockets and paste it at the end of the second one, saving the changes. The first WebSockets will need to be deleted later.
Hi
i got question How to wait for transaction confirmation for Unity webGL?
I have moved from this thread
I use this function to execute smart contract function in Unity WebGL
string resp = await MoralisInterface.ExecuteContractFunction(Constants.ADDRESS, Constants.ABI, Constants.Func_Mint_Token, pars, v, gas, gas);
no error but it return a transaction hash string. not wait for transaction confirmation.
There is nothing response when the transaction have confirmed or failed.
I found that React can do this but Iām not found how to do in unity
The string resp
is just a string. cannot await resp.wait()
How should I approach adding this sdk to an existing Unity 2D game?
I have a 2D game that needs to authenticate via Web3. User can be on Eth, polygon or Avax. Upon completion the user will update a contract on their respective chain.
Seems like the best way is to implement Web3 auth and use cloud functions to make the smart contract calls on level completion.
With that functionality in mind, what necessary packages should be imported and where should moralis related code live withing the Unity project? currently working with a 2D project.
You can use the Moralis Unity SDK for authentication and running contract calls. You can download the latest version here and thereās a tutorial on using it here.
yes, the current method doesnāt do this, and idt you can wait it
That isnt currently implemented but it will be in a future update
okā¦
I think i have to check transection overtime untill get the result.
Hi. I have this problem too, what was the solution? THX!
webgl connection only works on build, it will through that error when running it on the editor
Thanks for reply,
I hope this will be available soon.
I canāt use MoralisInterface.EvmContractFunctionInstance
and InsertContractInstance
on WebGL build. What Can I use instead of it?
Example:
Function f = MoralisInterface.EvmContractFunctionInstance("approve", chainId, "approve");
try something like this
string resp = await MoralisInterface.ExecuteContractFunction(Constants.MUG_CONTRACT_ADDRESS, Constants.MUG_ABI, Constants.MUG_CLAIM_FUNCTION, pars, new HexBigInteger("0x0"), gas, gas);
//contract address, abi,function,parameters,msg.value,gas,gas,
Can I use your example for the paid transaction in webgl.
I want to call this Openzeppelin ERC20 function:
My code in Unity:
object[] inputParams = new object[2];
inputParams[0] = new { internalType = "address", name = "spender", type = "address" };
inputParams[1] = new { internalType = "uint256", name = "addedValue", type = "uint256" };
// Function ABI Output parameters
object[] outputParams = new object[1];
outputParams[0] = new { internalType = "bool", name = "", type = "bool" };
// Function ABI
object[] abi = new object[1];
abi[0] = new { inputs = inputParams, name = "increaseAllowance", outputs = outputParams, stateMutability = "nonpayable", type = "function" };
// Convert token id to hex as this is what the contract call expects
object[] pars = new object[] { abi.ToString() };
// Contract address, abi, function name, pars, value, gas, gas price
string result = await MoralisInterface.ExecuteContractFunction(contractAddress, abi, functionName, pars, new HexBigInteger("0x0"), gas, gas);
I tested MoralisInterface.ExecuteContractFunction
on WebGL and it is not working, I get no respose. It works on the PC version but I get no response on WebGL.
string result = await MoralisInterface.ExecuteContractFunction(contractAddress, abi, "approve", pars, new HexBigInteger("0x0"), gas, price);
Please tell me can I call paid function from WebGL? I canāt find any example to call a paid transaction on WebGL. @dgoodrich @0xprof
Hi there !
Having strange behaviors since a weekā¦
1 - When I check the NFT owned by an address there is always a big delay between when the transaction is confirmed and when I can display it in game.
In here, and on the server log we can see that the transaction is made at 5:50pm:
But on the screenshot it only appears in game 13minutes later.
any idea why is that ?
2- also, the log shows a total of 1 NFT when we clearly see two results ?
3- Why some erc1155 shows token_url, others donāt ? (when I can both check the url on remix without pb)
Thanks for your help !
PS: did an other test and had to wait exactly 13minutes again before displaying it in-game.