async void Start()
    {
        string chain    = "ethereum";
        string network  = "rinkeby";
        string contract = "0x3a8A85A6122C92581f590444449Ca9e66D8e8F35";
        string tokenId  = "5";

        // fetch uri from chain
        string uri = await ERC1155.URI(chain, network, contract, tokenId);

        print("uri: " + uri);

        // fetch json from uri
        UnityWebRequest webRequest = UnityWebRequest.Get(uri);
        await webRequest.SendWebRequest();

        Response data = JsonUtility.FromJson <Response>(System.Text.Encoding.UTF8.GetString(webRequest.downloadHandler.data));

        // parse json to get image uri
        string imageUri = data.image;

        print("imageUri: " + imageUri);

        // fetch image and display in game
        UnityWebRequest textureRequest = UnityWebRequestTexture.GetTexture(imageUri);
        await textureRequest.SendWebRequest();

        this.gameObject.GetComponent <Renderer>().material.mainTexture = ((DownloadHandlerTexture)textureRequest.downloadHandler).texture;
    }
示例#2
0
    async void Start()
    {
        string chain    = "binance";
        string network  = "mainnet";
        string contract = "0x3E31F70912c00AEa971A8b2045bd568D738C31Dc";
        string tokenId  = "770";

        string uri = await ERC1155.URI(chain, network, contract, tokenId);

        print(uri);
    }
    async void Start()
    {
        string chain    = "avalanche";
        string network  = "testnet";
        string contract = "0xbDF2d708c6E4705824dC024187cd219da41C8c81";
        string account  = "0xdD4c825203f97984e7867F11eeCc813A036089D1";
        string tokenId  = "2";

        BigInteger balanceOf = await ERC1155.BalanceOf(chain, network, contract, account, tokenId);

        print(balanceOf);
    }
示例#4
0
    async void Start()
    {
        string chain    = "ethereum";
        string network  = "rinkeby";
        string contract = "0x2ebecabbbe8a8c629b99ab23ed154d74cd5d4342";

        string[] accounts = { "0xaCA9B6D9B1636D99156bB12825c75De1E5a58870", "0xaCA9B6D9B1636D99156bB12825c75De1E5a58870" };
        string[] tokenIds = { "17", "22" };

        List <BigInteger> batchBalances = await ERC1155.BalanceOfBatch(chain, network, contract, accounts, tokenIds);

        foreach (var balance in batchBalances)
        {
            print("BalanceOfBatch: " + balance);
        }
    }