您的位置:58脚本 > mora账号注册 Moralis 账户

mora账号注册 Moralis 账户

2023-04-13 20:29

mora账号注册 Moralis 账户

mora账号注册 Moralis 账户

mora账号注册

所有方法都扩展自 ​Moralis.SolanaAPI.account

balance

返回地址的 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"
}

getSPL

返回地址的 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",
  },
];

getNFTs

返回地址的 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",
  },
];

getPortfolio

返回地址的投资组合(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"
    }
  ]
}


阅读全文
以上是58脚本为你收集整理的mora账号注册 Moralis 账户全部内容。
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。
相关文章
© 2024 58脚本 58jiaoben.com 版权所有 联系我们
桂ICP备12005667号-28 Powered by CMS