所有方法都扩展自 Moralis.SolanaAPI.account
返回地址的 SOL 余额。
选项:
network
:要从中获取数据的网络集群。 有效值列在支持的网络上。 默认值主网。
address
:用户地址(即 6XU36wCxWobLx5Rtsb58kmgAJKVYmmVqy4SHXxENAyAe)。 如果指定,则附加到查询的用户将被忽略,而是使用地址。
你可以使用JS
、React
、curl
、Unity
来实现
// get mainnet SOL balance for the current user
const solBalance = await Moralis.SolanaAPI.account.balance();
// get devnet SOL balance for a given address
const options = {
network: "devnet",
address: "6XU36wCxWobLx5Rtsb58kmgAJKVYmMVqy4SHXxENAyAe",
};
const solBalance = await Moralis.SolanaAPI.account.balance(options);
import { useMoralisSolanaApi, useMoralisSolanaCall } from "react-moralis";
const { account } = useMoralisSolanaApi();
// get mainnet SOL balance for the current user
const { fetch, data, isLoading } = useMoralisSolanaCall(account.balance);
// get devnet SOL balance for a given address
const options = {
network: "devnet",
address: "6XU36wCxWobLx5Rtsb58kmgAJKVYmMVqy4SHXxENAyAe",
};
const { fetch, data, isLoading } = useMoralisSolanaCall(
account.balance,
options
);
curl -X "GET"
"https://solana-gateway.moralis.io/account/devnet/6XU36wCxWobLx5Rtsb58kmgAJKVYmMVqy4SHXxENAyAe/balance"
-H "accept: application/json"
-H "X-API-Key: MY-API-KEY"
using System.Collections.Generic;
using Moralis.SolanaApi.Models;
using Moralis.SolanaApi;
using MoralisWeb3ApiSdk;
public async void GetSolNativeBalance()
{
NativeBalance solBalance = await MoralisSolanaClient.SolanaApi.Account.Balance(NetworkTypes.mainnet, "6XU36wCxWobLx5Rtsb58kmgAJKVYmMVqy4SHXxENAyAe");
print(solBalance);
}
示例结果
{
"lamports": "500000000",
"solana": "0.5"
}
返回地址的 SPL 代币余额。
选项:
network
:要从中获取数据的网络集群。 有效值列在支持的网络上。 默认值主网。
address
:用户地址(即 HsXZnAba2...)。 如果指定,则附加到查询的用户将被忽略,而是使用地址。你可以使用JS
、React
、curl
、Unity
来实现
// get mainnet SPL token balance for the current user
const tokenBalance = await Moralis.SolanaAPI.account.getSPL();
// get devnet SPL token balance for a given address
const options = {
network: "devnet",
address: "6XU36wCxWobLx5Rtsb58kmgAJKVYmMVqy4SHXxENAyAe",
};
const tokenBalance = await Moralis.SolanaAPI.account.getSPL(options);
import { useMoralisSolanaApi, useMoralisSolanaCall } from "react-moralis";
const { account } = useMoralisSolanaApi();
// get mainnet SPL token balance for the current user
const { fetch, data, isLoading } = useMoralisSolanaCall(account.getSPL);
// get devnet SPL token balance for a given address
const options = {
network: "devnet",
address: "6XU36wCxWobLx5Rtsb58kmgAJKVYmMVqy4SHXxENAyAe",
};
const { fetch, data, isLoading } = useMoralisSolanaCall(
account.getSPL,
options
);
curl -X "GET"
"https://solana-gateway.moralis.io/account/devnet/6XU36wCxWobLx5Rtsb58kmgAJKVYmMVqy4SHXxENAyAe/tokens"
-H "accept: application/json"
-H "X-API-Key: MY-API-KEY"
using System.Collections.Generic;
using Moralis.SolanaApi.Models;
using Moralis.SolanaApi;
using MoralisWeb3ApiSdk;
public async void GetSPLTokens()
{
List<SplTokenBalanace> spltokens = await MoralisSolanaClient.SolanaApi.Account.GetSplTokens(NetworkTypes.mainnet, "6XU36wCxWobLx5Rtsb58kmgAJKVYmMVqy4SHXxENAyAe");
foreach(SplTokenBalanace spltoken in spltokens){
print(spltoken);
}
}
示例结果
[
{
associatedTokenAddress: "Dpmpwm93Amvj4uEFpYhjv8ZzfpgARq6zxKTi6mrj97gW",
mint: "BXWuzb3jEuGsGUe29xdApu8Z3jVgrFbr3wWdsZmLWYk9",
amountRaw: "100000000000",
amount: "100",
decimals: "9",
},
];
返回地址的 SPL NFT 余额。
选项:
network
:要从中获取数据的网络集群。 有效值列在支持的网络上。 默认值主网。
address
:用户地址(即 HsXZnAba2...)。 如果指定,则附加到查询的用户将被忽略,而是使用地址。你可以使用JS
、React
、curl
、Unity
来实现
// get mainnet SPL NFT balance for the current user
const nftBalance = await Moralis.SolanaAPI.account.getNFTs();
// get devnet SPL NFT balance for a given address
const options = {
network: "devnet",
address: "6XU36wCxWobLx5Rtsb58kmgAJKVYmMVqy4SHXxENAyAe",
};
const nftBalance = await Moralis.SolanaAPI.account.getNFTs(options);
import { useMoralisSolanaApi, useMoralisSolanaCall } from "react-moralis";
const { account } = useMoralisSolanaApi();
// get mainnet SPL NFT balance for the current user
const { fetch, data, isLoading } = useMoralisSolanaCall(account.getNFTs);
// get devnet SPL NFT balance for a given address
const options = {
network: "devnet",
address: "6XU36wCxWobLx5Rtsb58kmgAJKVYmMVqy4SHXxENAyAe",
};
const { fetch, data, isLoading } = useMoralisSolanaCall(
account.getNFTs,
options
);
curl -X "GET"
"https://solana-gateway.moralis.io/account/devnet/6XU36wCxWobLx5Rtsb58kmgAJKVYmMVqy4SHXxENAyAe/nft"
-H "accept: application/json"
-H "X-API-Key: MY-API-KEY"
using System.Collections.Generic;
using Moralis.SolanaApi.Models;
using Moralis.SolanaApi;
using MoralisWeb3ApiSdk;
public async void GetSPLNft()
{
List<SplNft> SplNFTbal = await MoralisSolanaClient.SolanaApi.Account.GetNFTs(NetworkTypes.mainnet, "6XU36wCxWobLx5Rtsb58kmgAJKVYmMVqy4SHXxENAyAe");
foreach(SplNft splnft in SplNFTbal){
print(splnft);
}
}
示例结果
[
{
associatedTokenAddress: "Dpmpwm93Amvj4uEFpYhjv8ZzfpgARq6zxKTi6mrj97gW",
mint: "BXWuzb3jEuGsGUe29xdApu8Z3jVgrFbr3wWdsZmLWYk9",
amountRaw: "100000000000",
amount: "100",
decimals: "9",
},
];
返回地址的投资组合(SOL 余额、SPL 代币余额、SPL NFT 余额)。
选项:
network
:要从中获取数据的网络集群。 有效值列在支持的网络上。 默认值主网。
address
:用户地址(即 HsXZnAba2...)。 如果指定,则附加到查询的用户将被忽略,而是使用地址。你可以使用JS
、React
、curl
、Unity
来实现
// get mainnet NFT balance for the current user
const portfolio = await Moralis.SolanaAPI.account.getPortfolio();
// get devnet NFT balance for a given address
const options = {
network: "devnet",
address: "6XU36wCxWobLx5Rtsb58kmgAJKVYmMVqy4SHXxENAyAe",
};
const portfolio = await Moralis.SolanaAPI.account.getPortfolio(options);
import { useMoralisSolanaApi, useMoralisSolanaCall } from "react-moralis";
const { account } = useMoralisSolanaApi();
// get mainnet SPL NFT balance for the current user
const { fetch, data, isLoading } = useMoralisSolanaCall(account.getPortfolio);
// get devnet SPL NFT balance for a given address
const options = {
network: "devnet",
address: "6XU36wCxWobLx5Rtsb58kmgAJKVYmMVqy4SHXxENAyAe",
};
const { fetch, data, isLoading } = useMoralisSolanaCall(
account.getPortfolio,
options
);
curl -X "GET"
"https://solana-gateway.moralis.io/account/devnet/6XU36wCxWobLx5Rtsb58kmgAJKVYmMVqy4SHXxENAyAe/portfolio"
-H "accept: application/json"
-H "X-API-Key: MY-API-KEY"
using System.Collections.Generic;
using Moralis.SolanaApi.Models;
using Moralis.SolanaApi;
using MoralisWeb3ApiSdk;
public async void GetSPLPortfolioBal()
{
Portfolio PortfolioBal = await MoralisSolanaClient.SolanaApi.Account.GetPortfolio(NetworkTypes.mainnet, "6XU36wCxWobLx5Rtsb58kmgAJKVYmMVqy4SHXxENAyAe");
print(PortfolioBal);
}
示例结果
{
"nativeBalance": {
"lamports": "6000000000",
"solana": "6"
},
"nfts": [
{
"associatedTokenAddress": "6Fk96aAvPhV9gZvGXp9mMw1YwiScPX3pm1RwWn11eGrQ",
"mint": "BpCcCVU4pK2rcvgduCzScaBhqKEKaMukcejkDhJWRyPv"
}
],
"tokens": [
{
"associatedTokenAddress": "Dpmpwm93Amvj4uEFpYhjv8ZzfpgARq6zxKTi6mrj97gW",
"mint": "BXWuzb3jEuGsGUe29xdApu8Z3jVgrFbr3wWdsZmLWYk9",
"amountRaw": "100000000000",
"amount": "100",
"decimals": "9"
}
]
}
检查仪表板中的错误日志对于任何Moralis问题,首先要检查的是仪表板中的日志部分。未捕获错误:未启用以太坊的浏览器确保您的浏...
在安装ZooKeeper之前,请确保你的系统是在以下任一操作系统上运行:任意Linux OS- 支持开发和部署。适合演示应用程序。 Windows ...
Kafka在“org.apache.kafka.tools。"下打包的工具。 工具分为系统工具和复制工具。系统工具可以使用运行类脚本从命令行运行系统...
首先让我们开始实现单节点单代理配置,然后我们将我们的设置迁移到单节点多代理配置。希望你现在可以在你的机器上安装 Java,Zoo...
主要记录了Hadoop各个组件的基本原理,处理过程和关键的知识点等,包括HDFS、YARN、MapReduce等。本教程内容来源于 PennyWong更...
关键词:while,for,repeat,foreverVerilog循环语句有4种类型,分别是while,for,repeat,和forever循环。循环语句只能在always...
cover-view基础库 1.4.0 开始支持,低版本需做兼容处理。覆盖在原生组件之上的文本视图。可覆盖的原生组件包括map、video、canva...
navigator基础库 1.0.0 开始支持,低版本需做兼容处理。页面链接。属性名类型默认值说明targetStringself在哪个目标上发生跳转,...
wx.openVideoEditor(Object object)基础库 2.12.0 开始支持,低版本需做兼容处理。打开视频编辑器参数Object object属性类型默认...