changes
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
using System.Numerics;
|
||||
using UnityEngine;
|
||||
using Web3Unity.Scripts.Library.ETHEREUEM.EIP;
|
||||
|
||||
public class ERC721BalanceOfExample : MonoBehaviour
|
||||
{
|
||||
async void Start()
|
||||
{
|
||||
string contract = "0x9123541E259125657F03D7AD2A7D1a8Ec79375BA";
|
||||
string account = "0xd25b827D92b0fd656A1c829933e9b0b836d5C3e2";
|
||||
|
||||
BigInteger balance = await ERC721.BalanceOf(contract, account);
|
||||
print(balance);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 75d27837ef25c4d2992393ea70605c11
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,19 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Web3Unity.Scripts.Library.ETHEREUEM.EIP;
|
||||
|
||||
public class ERC721OwnerOfBatchExample : MonoBehaviour
|
||||
{
|
||||
async void Start()
|
||||
{
|
||||
string contract = "0x47381c5c948254e6e0E324F1AA54b7B24104D92D";
|
||||
string[] tokenIds = { "33", "29" };
|
||||
string multicall = "0x77dca2c955b15e9de4dbbcf1246b4b85b651e50e"; // optional: multicall contract https://github.com/makerdao/multicall
|
||||
|
||||
List<string> batchOwners = await ERC721.OwnerOfBatch(contract, tokenIds, multicall);
|
||||
foreach (string owner in batchOwners)
|
||||
{
|
||||
print("OwnerOfBatch: " + owner);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8daf09cb680004087b202594bdd8adf1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,13 @@
|
||||
using UnityEngine;
|
||||
using Web3Unity.Scripts.Library.ETHEREUEM.EIP;
|
||||
|
||||
public class ERC721OwnerOfExample : MonoBehaviour
|
||||
{
|
||||
async void Start()
|
||||
{
|
||||
string contract = "0x06dc21f89f01409e7ed0e4c80eae1430962ae52c";
|
||||
string tokenId = "0x01559ae4021a565d5cc4740f1cefa95de8c1fb193949ecd32c337b03047da501";
|
||||
string ownerOf = await ERC721.OwnerOf(contract, tokenId);
|
||||
print(ownerOf);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3813571b518fd457bbad45d1347dc4cd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
15
Assets/Web3Unity/Scripts/Prefabs/ERC721/ERC721URIExample.cs
Normal file
15
Assets/Web3Unity/Scripts/Prefabs/ERC721/ERC721URIExample.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using UnityEngine;
|
||||
using Web3Unity.Scripts.Library.ETHEREUEM.EIP;
|
||||
using Web3Unity.Scripts.Library.Ethers.Providers;
|
||||
|
||||
public class ERC721URIExample : MonoBehaviour
|
||||
{
|
||||
async void Start()
|
||||
{
|
||||
string contract = "0x06dc21f89f01409e7ed0e4c80eae1430962ae52c";
|
||||
string tokenId = "0x01559ae4021a565d5cc4740f1cefa95de8c1fb193949ecd32c337b03047da501";
|
||||
|
||||
string uri = await ERC721.URI(contract, tokenId);
|
||||
print(uri);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 925dc0696e2c24348975c2f9c518476f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 664760b4705f5d747bc1e90125b61304
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,41 @@
|
||||
using UnityEngine;
|
||||
using Web3Unity.Scripts.Library.ETHEREUEM.EIP;
|
||||
|
||||
public class AllErc721 : MonoBehaviour
|
||||
{
|
||||
public string[] nftContracts;
|
||||
public int amountOfTokenIdsToSearch;
|
||||
public int tokenIDStart; // set this as a starting point as needed
|
||||
string account;
|
||||
int balanceSearched;
|
||||
|
||||
async void Start()
|
||||
{
|
||||
// This is the account taken from the user login scene
|
||||
account = PlayerPrefs.GetString("Account");
|
||||
// Searches through your listed contracts
|
||||
foreach (string contract in nftContracts)
|
||||
{
|
||||
int balance = await ERC721.BalanceOf(contract, account);
|
||||
Debug.Log("Balance of contract " + contract + ": " + balance);
|
||||
// if i is less than the selected amount of tokenIDs to search, keep searching
|
||||
for (int i = 1; i < amountOfTokenIdsToSearch; i++)
|
||||
{
|
||||
// if balanceSearched is less than the balance for each contract, keep searching
|
||||
if (balanceSearched < balance)
|
||||
{
|
||||
Debug.Log("Searching" + (tokenIDStart + i));
|
||||
string ownerOf = await ERC721.OwnerOf(contract, (tokenIDStart + i).ToString());
|
||||
// if token id id matches the account from login, print the tokenID and get the URI
|
||||
if (ownerOf == account)
|
||||
{
|
||||
string uri = await ERC721.URI(contract, (tokenIDStart + i).ToString());
|
||||
Debug.Log("TokenID: " + (tokenIDStart + i));
|
||||
Debug.Log("Token URI: " + uri);
|
||||
balanceSearched++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c9b3d2893e2892a4d962a7c0348f71c0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user