Skip to content

Commit 1d27856

Browse files
add ability to fetch any contract's balance
1 parent a481b61 commit 1d27856

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

Assets/Thirdweb/Scripts/Contract.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ public Contract(string chain, string address, string abi = null) : base(abi != n
3838
this.marketplace = new Marketplace(chain, address);
3939
}
4040

41+
public async Task<CurrencyValue> GetBalance()
42+
{
43+
return await Bridge.InvokeRoute<CurrencyValue>($"sdk{separator}getBalance", Utils.ToJsonStringArray(address));
44+
}
45+
4146
/// <summary>
4247
/// Read data from a contract
4348
/// </summary>

Assets/WebGLTemplates/Thirdweb/lib/thirdweb.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ w.bridge.invoke = async (route, payload) => {
8585
if (prop && routeArgs.length === 2) {
8686
const result = await w.thirdweb[prop][routeArgs[1]](...parsedArgs);
8787
return JSON.stringify({ result: result }, bigNumberReplacer);
88+
} else if (routeArgs.length === 2) {
89+
const result = await w.thirdweb[routeArgs[1]](...parsedArgs);
90+
return JSON.stringify({ result: result }, bigNumberReplacer);
8891
} else {
8992
throw "Invalid Route";
9093
}

0 commit comments

Comments
 (0)