Ethereum Unity3D Boilerplate Questions

The update has been merged and posted to the repo.

1 Like

Wuuut :raised_hands:t4::raised_hands:t4::raised_hands:t4::raised_hands:t4:

Any advice on how to update the files without uninstall + reinstall on Unity ?

1 Like

Read through before doing :slight_smile: If you made any changes to the Moralis files (not under example) you will lose these changes.

  1. Backup your project!!!
  2. Download the new release (currently moralisweb3sdk_v1_1_0.unitypackage)
  3. Under Assets->MoralisWeb3ApiSdk DELETE:
    a. Folder: Moralis
    b. Folders: All three WalletConnect folders
    c. The seven (7) moralis script files in the MoralisWeb3ApiSdk folder.
  4. Under Assets delete the WebGLTemplates.
  5. Drag the release package into the Assets folder.
  6. When the import window appears, deselect and then re-select the Eamples option, this excludes any unchanged files.
  7. Import the package.
  8. If any of your custom files are now missing, re-apply from your backup copy.
1 Like

Does the SDK work just as well with Unity 2D builds?

1 Like

Yes, though we do not have any examples of this yet.

Hi, I want to achieve three things for Unity WebGL.

  • Checking the user’s wallet (Metamask) network such as eth, bsc, polygon etc.
  • Sending the wallet configuration request to Metamask.
  • Sending the adding coin request to Metamask.

Here are some examples of my questions. Can we achieve this using webgl?

1 Like

After building the project for desktop (PC) is anyone able to connect wallet with QR?

1 Like

Yes - what is the issue you are seeing?

Sorry it took a day to get back - I had to research through these.

The current version of the brawer wallet bridge is not returning this information though it is available from the wallet. The other build types (those that use Wallet Connect instead of Web3) already return this information so this looks like a good feature to add.

If you are referring to the icon and message that appear for the connection request then yes you can modify this to send you own information. If you are referring to something else please let me know.

Do you mean transferring coins and tokens from one account to another, accepting payments, minting tokens and NFTs? Yes, Moralis SDK enables you to do this.

If you mean I have a token but it does not show up in Metamask, programmatically make Metamask show the token, then no. However you can use the Web3Api endpoints and operations to retrieve and display any (on the supported chains) balance, tokens owned, NFTs owned by the connected wallet.

Regards,

David

1 Like

Hi there !
Digging your AwardableController script, amazing stuff!
Is there a way to have a glimpse at the smart contract ? or template ?

It seems strange that the player has to sign the transaction when claiming the nft. Is to make him pay the fees ?
also, i am interested in how you automated the transfer from the contract (and contract owner) to the player (without having to sign each transaction manually)

Thanks a lot !

1 Like

yes, the player pay the fees
there is no automation, the player pay the fees and collect the nft so, the contract owner isnt needed
@dgoodrich for the smart contract

1 Like

Thank you!

Sure, with the caveat that they are for demo purposes only.

Not signing at that point - as @0xprof mentioned this is to authorize payment of the gas fees.

I used two contracts, one to hold the NFTs, the second was used to call the first contract to perform the original mint and is written so that the second contract is the owner of the NFTs. This allows the single call transfer :slight_smile:

1 Like

Please DM me in Discord and I will post them there. The Forum does not allow us to upload files (other than pics).

1 Like

HI !
Thanks a lot for this !
What is your discord ?

My Discord handle is Xactant#0844

For some reasons my send custom token function doesn’t work anymore… (it always worked fine)

Having this “Invalid amount” error now:

public async void SendCustomTokenWithCustomGas()
    {

        BigInteger cost = new BigInteger(1000000000000000000);
        _amount = new BigInteger((double)cost * amount);

        MoralisInterface.InsertContractInstance("AKT", ABIAkt, "mumbai", tokenAddress);
        // Set gas estimate
        HexBigInteger gas = new HexBigInteger(80000);
        object[] pars = { receiverAccount, _amount };
        string result = await MoralisInterface.SendEvmTransactionAsync("AKT", "mumbai", "transfer", senderAccount, gas, new HexBigInteger("0x0"), pars);

        print(result);
    }

My contract works well on remix. Any idea where it might come from ?

I tried to play with the gas fees but no change.

Hi I am having some issues using the Moralis functions in my custom scripts outside of the example scene. Everytime I make a MoralisInterface call such as -
Nft resp = await MoralisInterface.GetClient().Web3Api.Token.GetTokenIdMetadata(contract, token, ChainList.eth);

I receive the following error - NullReferenceException: Object reference not set to an instance of an object

This is happening with any calls/functions I try with Moralis. In my scripts I have
using Moralis; using MoralisWeb3ApiSdk; using Moralis.Web3Api.Client; using Moralis.Web3Api.Models;

And because my scene is loaded after the sign in screen, I do not have a MoralisSetup gameObject for that scene.

Any ideas what I’m doing wrong and how can I properly access moralis calls from any script?

do you have enough tokens ?
are you on the lastest sdk version ?

have you experimented with HexBigInteger instead of BigInteger ?

have you tried logging out and then trying to connect (from the authentication scene) and the signing of message ?
make sure you are using latest sdk version ?
and also make sure your datas are defined and correct ?
also take a look at the docs https://docs.moralis.io/moralis-dapp/web3-sdk/token#gettokenidmetadata

Hi dgoodrich ! please tell me How can i write contract in unity with moralis ?