Ethereum Unity3D Boilerplate Questions

can you check if there is an error, development build usually show all the errors the app encountered and you can also use android studio to try to debug it and also try unity remote

can you check your moralis logs to see if there is any errors, and i see the signature got through , is the error breaking any part of the code ?

you mean for build on webgl, @dgoodrich is currently working on this

Server logs were shared in my OG post.

Server log error:
2022-02-18T12:33:28.495Z - Error: Signing message has expired.
at /moralis-server/lib/Adapters/Auth/moralisEth.js:48:13
at runMicrotasks ()
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async Promise.all (index 0)
2022-02-18T12:33:26.010Z - Error: Invalid session token
at Object.getAuthForSessionToken (/moralis-server/lib/Auth.js:114:11)
at runMicrotasks ()
at processTicksAndRejections (node:internal/process/task_queues:96:5)

idk, is your pc time correct ? can you check this, if it is try to get the sdk again and test out the demo scene

Continuing the discussion from Ethereum Unity3D Boilerplate Questions:

Hi there ! I don’t see any errors in the log.
This is a small part of the log,

Followed by this

Since the server time retrieval failed, there should be errors in the log of you server.
There are two possible causes:

  1. You are not connected to the server (check that when you pasted your sever uri in the MoralisSetup Moralis Server URI field it is complete and correct. A common mistake is to paste into and not over the default text in the field.
  2. Your Moralis server needs to be re-started, or is not up to date. To correct either, re-start your server.

Regards,

David

I am currently working on this.
The WebGL / Browser Wallet interface is done and working. I am currently cleaning up the code. This is going to be a major change and may break some current projects so I will probably do a pre-release for teams to examine.

Hi, can i have a sample code on subscribe livequery on playercontroller?

using Moralis;
using Moralis.Platform.Objects;
MoralisLiveQueryClient<Hero> heroSubscription = moralis.Query<Hero>().Subscribe(callbacks);

is this the right direction? tq

1 Like

Try this format:

MoralisQuery<Hero> q = MoralisInterface.GetClient().Query<Hero>();
MoralisLiveQueryController.AddSubscription<Hero>("Hero", q, callbacks);

The MoralisLiveQueryController will respond to Unity life cycles to pauses and re-establish your queries automatically.

Let me know if you have any issues.

David

Hi there !
I would like to send an amount of ERC20 from one address to an other within Unity.
I couldn’t find a proper function for with moralis that takes in an receiver address, a token address and an amount.
So, I made a “transfer” function within the smart contract and would like to interact with it from unity with moralis.

I found the RunContractFunction methode but i am struggling to use this code exemple:

// Function ABI input parameters
object[] inputParams = new object[1];
inputParams[0] = new { internalType="uint256", name="id", type="uint256" };
// Function ABI Output parameters
object[] outputParams = new object[1];
outputParams[0] = new { internalType="string", name="", type="string" };
// Function ABI
object[] abi = new object[1];
abi[0] = new { inputs=inputParams, name="uri", outputs=outputParams, stateMutability="view", type="function" };

// Define request object
RunContractDto rcd = new RunContractDto()
{
    Abi = abi,
    Params = new { id = "15310200874782" }
};

// Call contract function, response is always a string.
string resp = MoralisInterface.GetClient().Web3Api.Native.RunContractFunction("0x698d7D745B7F5d8EF4fdB59CeB660050b3599AC3", "uri", rcd, ChainList.mumbai);

I would like to use my function called “transfer” that takes in an Address and uint256 of the smart contract “0x0000”.
Any guidance would be much appreciated ! thanks !

hey, to send a custom token, you need to have the contract abi in your code, take a look at this
(https://github.com/0xPr0f/Moralis-Unity/blob/master/Assets/SendCustomToken.cs) this was a template i made.
you can also read down from here to see how it is done and the parameters
(https://github.com/ethereum-boilerplate/ethereum-unity-boilerplate#web3)

1 Like

Thank you ! this helped me a lot !
However, when I try to confirm the payement with imtoken wallet, it keeps saying “network is busy, please try again later”. On metamask it says “internal JSON-RPC error” and on trust wallet it says nothing.
any idea where this might come from ?

Thanks again !

1 Like

Also, is it the same function for sending nfts?

I would need to be able to exchange an Erc20 for an erc1155 minted nft between two accounts.
Security wise, how can I be sure both transactions happen at the same time ?

Thanks again !

hey, for imtoken, it could be the wallet or network specifically
for metamask, did you set the wallet connection to metamask? and did you set the chain id ?
for wallet connect too, did you set the chainid ?

and that code sample allows you to call a contract function, it can be anything as long as it is a function in the contract abi so, it isnt specific (you can use it to call a smart contract function)

1 Like

Hello im new here and I have a noob question, … So I logged in succesfuly using the wallet connect QR code … I have the wallet address displaying on the screen but how do I display certain nfts from the wallet onto a canvas image … thanks for the help … !

1 Like

you can use the getnft web3api method for that
(https://github.com/ethereum-boilerplate/ethereum-unity-boilerplate#getnfts)
take a look at this in practical usage
(https://github.com/0xPr0f/Moralis-Unity/blob/master/README.md)
then you have to get the image and then render it on a image object in unity
this is an example in more complex code
(https://github.com/0xPr0f/chillHouse/blob/9cf6e3c19676fdf121e55fa14e7341f929c59ab2/Assets/Script/CovelentData.cs#L209)
here, the image is been rendered

2 Likes

hey bro thanks for answering … going to check it out right now . .any questions I will get back to you … cheers my man !

Hi @dgoodrich

Regarding this: https://github.com/ethereum-boilerplate/ethereum-unity-boilerplate/issues/32#issue-1119418735

What is ETA for merging in-Browser Wallet for WebGL in the main release?

1 Like