forked from xJonathanLEI/starknet-rs
-
Notifications
You must be signed in to change notification settings - Fork 1
/
erc20_balance.rs
35 lines (31 loc) · 1.02 KB
/
erc20_balance.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
use starknet::{
core::types::{BlockId, BlockTag, Felt, FunctionCall},
macros::{felt, selector},
providers::{
jsonrpc::{HttpTransport, JsonRpcClient},
Provider, Url,
},
};
#[tokio::main]
async fn main() {
let provider = JsonRpcClient::new(HttpTransport::new(
Url::parse("https://starknet-sepolia.public.blastapi.io/rpc/v0_7").unwrap(),
));
let tst_token_address =
felt!("0x07394cbe418daa16e42b87ba67372d4ab4a5df0b05c6e554d158458ce245bc10");
let call_result =
provider
.call(
FunctionCall {
contract_address: tst_token_address,
entry_point_selector: selector!("balanceOf"),
calldata: vec![
Felt::from_hex("YOUR_ACCOUNT_CONTRACT_ADDRESS_IN_HEX_HERE").unwrap()
],
},
BlockId::Tag(BlockTag::Latest),
)
.await
.expect("failed to call contract");
dbg!(call_result);
}