Do you need to create Gnosis Chain dapps utilizing a free Gnosis API? If that’s the case, you’ve come to the suitable place! In at the moment’s article, we’ll introduce you to Moralis’ Gnosis API – the final word software for constructing decentralized purposes (dapps) on Gnosis Chain. The Gnosis API options many distinguished endpoints you should utilize to fetch the whole lot from token costs to pockets balances with solely single traces of code. In the event you’re desirous to know precisely how this works, listed here are three Gnosis API endpoint examples:
getWalletTokenBalances() – Get an array of all token balances of any pockets:const response = await Moralis.EvmApi.token.getWalletTokenBalances({
“chain”: “0x64”,
“handle”: “0x88ad09518695c6c3712ac10a214be5109a655671”
}); getBlock() – Fetch information for any block: const response = await Moralis.EvmApi.block.getBlock({
“chain”: “0x64”,
“blockNumberOrHash”: “23233”
}); getWalletNFTs() – Question an array of all NFTs owned by a pockets: const response = await Moralis.EvmApi.nft.getWalletNFTs({
“chain”: “0x64”,
“handle”: “0x88ad09518695c6c3712ac10a214be5109a655671”
});
In the event you’re searching for a extra detailed breakdown of how one can leverage the Gnosis API to construct dapps, be part of us on this article as we cowl the ins and outs of this industry-leading interface!
Additionally, if you wish to name the assorted endpoints of the Gnosis API your self, don’t neglect to enroll with Moralis. You possibly can arrange an account free of charge, and also you’ll immediately have the ability to construct smarter and quicker on Gnosis Chain!
Overview
We’ll begin at the moment’s article by exploring the ins and outs of Gnosis Chain. From there, we’ll cowl a few of the advantages of constructing dapps on this community. We are going to then introduce you to the Moralis Gnosis API – the {industry}’s premier software for Gnosis improvement. Subsequent, we’ll dive into our Gnosis API tutorial, the place we’re going to indicate you the best way to get the token balances of any pockets in three steps:
Get Your Moralis API KeyWrite a Script Calling the getWalletTokenBalances() EndpointExecute the Code
Lastly, we’ll discover some Gnosis API use instances, providing you with some inspiration for what you’ll be able to construct with our industry-leading Web3 improvement software!
So, should you’re already aware of Gnosis, be happy to skip the preliminary two sections and bounce straight into the ”Moralis’ Gnosis API – Best Approach to Construct Gnosis Dapps” half.
Nonetheless, should you’re new to Gnosis, be part of us within the following part as we briefly discover the intricacies of this community!
What’s Gnosis? Gnosis Chain Defined
Martin Köppelman and Stefan George based Gnosis again in 2015 when the group – on the time – was constructing prediction markets. In 2020, Gnosis introduced plans to totally decentralize right into a DAO (decentralized autonomous group). Only one yr later, in 2021, the GnosisDAO and xDAI communities voted to mix their ecosystems to create Gnosis Chain!
So, what’s Gnosis Chain?
Gnosis Chain is an Ethereum sidechain secured by a world community of 160,000+ validators worldwide. The community’s various set of validators and give attention to community-driven governance ensures that Gnosis Chain stays impartial in its operations.
Moreover, Gnosis Chain makes use of an progressive dual-token mannequin with two central tokens: xDai and GNO. XDai is a stablecoin pegged to the USD, and it’s used for transactions, charges, and funds on Gnosis Chain. GNO, then again, supplies safety through Gnosis’ consensus-layer Gnosis Beacon Chain. Consequently, GNO is used for staking, protocol safety, and neighborhood governance.
Along with the Ethereum sidechain, Gnosis hosts an in depth ecosystem of different merchandise. Two distinguished examples embody CoW and Secure. CoW, quick for ”coincidence of needs”, is a permissionless decentralized change (DEX) permitting customers to commerce ERC-20 tokens. Secure is an account abstraction chief on the Ethereum community with the aim of accelerating the transition to sensible contract accounts.
That briefly covers Gnosis and Gnosis Chain. So, let’s now discover some advantages of constructing on this community!
Why Ought to You Construct On Gnosis Chain?
Gnosis Chain affords a robust playground permitting you, as a developer, to innovate and construct artistic Web3 initiatives. Nonetheless, why do you have to decide to construct on Gnosis Chain? To reply this query, let’s discover 5 distinguished advantages of this blockchain community:
Swift Efficiency: With a powerful five-second block time, you’ll be able to expertise fast transaction confirmations. Globally Secured: With an in depth set of greater than 160,000 validators worldwide, Gnosis Chain is ready to provide excessive safety.Value-Environment friendly: Lower your expenses by attaining environment friendly operations at simply $0.000099 per 100k gasoline.100% Uptime: Guarantee your dapps run with none points with Gnosis Chain’s spectacular 100% uptime. EVM-Appropriate: Gnosis Chain is EVM-compatible, which means you’ll be able to leverage lots of the similar instruments you’d use for Ethereum improvement.
Now, with an summary of the advantages of Gnosis Chain, let’s discover the best option to construct dapps on the community!
Moralis’ Gnosis API – Best Approach to Construct Gnosis Dapps
The simplest option to construct on Gnosis Chain is to leverage Moralis’ Gnosis API. The Gnosis API from Moralis is an industry-leading software that permits you to unlock the total potential of Gnosis Chain. With the options of this interface, you’ll be able to effortlessly construct dapps quicker and extra effectively. In flip, you’ll save an abundance of improvement time and sources!
So, why do you have to be part of a few of the largest names in Web3 and construct with Moralis? To reply this query, let’s discover a few of the foremost advantages of the Moralis Gnosis API:
Actual-Time Information: Keep up-to-date and replace your customers with real-time information feeds. Correct Information: Guarantee information integrity with constant and exact information instantly from Gnosis Chain.Totally Listed Information: Entry the totally listed and ready-to-use information on Gnosis Chain. Prompt Setup: Keep away from any hassles of preliminary setups and bounce straight into improvement. Scalability: All of Morlis’ APIs are constructed to scale. Consequently, the Gnosis API will scale together with your initiatives, making certain easy and hassle-free efficiency. Knowledgeable Help: Entry world-class assist from our staff of skilled blockchain consultants.And far more!
The Gnosis API suite consists of industry-leading interfaces, and within the following part, we’ll introduce you to 3 distinguished examples!
Pockets API
The Moralis Pockets API is the final word software for integrating pockets performance into dapps. The Pockets API helps 500+ million addresses throughout all main EVM chains, together with Gnosis Chain, Ethereum, Polygon, and lots of others. Moreover, this interface boasts an array of distinguished options, unparalleled scalability, and distinctive flexibility, making it stand out because the {industry}’s premier API for pockets information!
The Pockets API options many distinguished endpoints, and with solely single traces of code, you’ll be able to seamlessly fetch all tokens, NFTs, native tokens, transactions, and so forth., and verify the exercise of any pockets on Gnosis Chain.
For instance the accessibility of this software, right here’s an instance of how one can get all NFTs owned by a pockets utilizing the getWalletNFTs() endpoint:
const response = await Moralis.EvmApi.nft.getWalletNFTs({
“chain”: “0x64”,
“handle”: “0x88ad09518695c6c3712ac10a214be5109a655671”
});
Because of the multi-chain capabilities of the Pockets API, you should utilize the identical software to create cross-chain appropriate dapps that combine pockets stats, real-time NFT switch information, decoded transactions, and far more!
Blockchain API
Moralis’ Blockchain API permits you to seamlessly unlock the facility of uncooked and decoded blockchain information with precision and tempo. As such, when working with this industry-leading interface, it has by no means been simpler to investigate sensible contracts, arrange real-time alerts, and construct highly effective buying and selling platforms!
With the Blockchain API, you’ll be able to seamlessly question the contents of any block on Gnosis Chain with a single line of code. The response provides you with a bunch of knowledge in regards to the block, together with a timestamp, hash, quantity, log blooms, the miner, gasoline used, and far more.
To indicate you the way straightforward it’s to work with the Blockchain API, right here’s a Blockchain API instance of how one can get the contents of a block utilizing the getBlock() endpoint:
const response = await Moralis.EvmApi.block.getBlock({
“chain”: “0x64”,
“blockNumberOrHash”: “23233”
});
What’s extra, identical to the Pockets API, the Blockchain API additionally helps a number of networks. Consequently, you should utilize this software to construct cross-chain appropriate dapps that combine sensible contract logs, occasions, handle labels, and so forth.
Token API
The Moralis Token API is the final word software for token information, with protection spanning all tokens on all main chains, together with Gnosis Chain, BNB Good Chain, Ethereum, Ploygon, and lots of others!
With this interface, you’ll be able to effortlessly get and combine real-time token costs, pockets balances, and far more into your dapps. Consequently, when working with the Token API, constructing DEXs, portfolio trackers, token analytics instruments, and so forth., has by no means been simpler!
To focus on the accessibility of the Token API, right here’s an instance of how you should utilize the getWalletTokenBalances() endpoint to get all token balances of a pockets:
const response = await Moralis.EvmApi.token.getWalletTokenBalances({
“chain”: “0x64”,
“handle”: “0x88ad09518695c6c3712ac10a214be5109a655671”
});
Additionally, since Moralis’ Token API helps all main chains, you should utilize this interface to construct cross-chain initiatives integrating token metadata, stats, transfers, and far more!
Nonetheless, the three interfaces above are only a few examples, and there’s much more to the Gnosis API suite. If you wish to discover all of the instruments and accessible endpoints, take a look at our Web3 API web page or the Web3 API documentation!
Gnosis API Tutorial: Easy methods to Get the Token Balances of any Pockets
On this part, we’ll present an in-depth tutorial displaying you the best way to get the token balances of any pockets on the Gnosis Chain. And because of the accessibility of the Moralis Gnosis API, you’ll be able to accomplish this in three easy steps:
Get Your Moralis API KeyWrite a Script Calling the getWalletTokenBalances() EndpointExecute the Code
Nonetheless, you should take care of a number of important stipulations earlier than you may get going!
Conditions for Utilizing the Gnosis API
The Gnosis API helps a number of programming languages. Nonetheless, on this tutorial, we’ll be utilizing JavaScript. As such, be sure you have the next prepared earlier than you proceed:
Step 1: Get Your Moralis API Key
The very first thing you’ll have to name the Gnosis API is a Moralis API key. Consequently, begin by clicking on the ”Begin for Free” button on the high proper to enroll with Moralis:
With an account at hand, now you can click on on the ”Settings” tab, scroll all the way down to the ”API Keys” part, and replica your key:
Please hold it for now, as you’ll use it within the subsequent step!
Step 2: Write a Script Calling the getWalletTokenBalances() Endpoint
Open your most well-liked built-in improvement surroundings, arrange a brand new mission, and run the next command within the root folder to put in the Moralis SDK:
npm set up moralis @moralisweb3/common-evm-utils
Subsequent, create a brand new ”index.js” file and add the next code:
const Moralis = require(“moralis”).default;
const { EvmChain } = require(“@moralisweb3/common-evm-utils”);
const runApp = async () => {
await Moralis.begin({
apiKey: “YOUR_API_KEY”,
// …and every other configuration
});
const handle = “0x88ad09518695c6c3712ac10a214be5109a655671”;
const chain = “0x64”;
const response = await Moralis.EvmApi.token.getWalletTokenBalances({
handle,
chain,
});
console.log(response.toJSON());
};
runApp();
From right here, begin by changing YOUR_API_KEY with the important thing you fetched within the earlier step:
Afterward, configure the handle fixed by assigning it the handle of the pockets from which you need to question the token balances. What’s extra, make it possible for the chain const is about to 0x64:
We then go alongside each handle and chain as parameters when calling the getWalletTokenBalances() endpoint:
That’s it for the code; all that continues to be from right here is operating the script!
Step 3: Execute the Code
For the ultimate step, open a brand new terminal and run this command within the root folder of the mission:
node index.js
In return, it’s best to get a response containing an array of all tokens held by the pockets in query. And for every token, you’ll additionally get the present steadiness. It ought to look one thing like this:
[
{
token_address: ‘0xfd135b71c8dbb1c2bd052edafc9cba77dd2a7d69’,
symbol: ‘xdai.firstchef.net’,
name: ‘xdai.firstchef.net’,
logo: null,
thumbnail: null,
decimals: 18,
balance: ‘600000000000000000000000000’,
possible_spam: true
},
//…
[
Congratulations; you now know how to get all token balances of any wallet on Gnosis Chain!
You can follow the same steps to call any other endpoint for Gnosis Chain. You simply need to make minor configurations to the parameters and change the endpoint during the second step!
Gnosis API Use Cases
Now that you know how to fetch data from Gnosis Chain using our API, let’s also look at three examples of what you can build using this industry-leading tool:
Governance Platforms: Build a community-driven decision-making platform that allows users to participate in polls and shape the future of your ecosystem. Wallet Platforms: Set up your own multi-sig wallet infrastructure like Safe, optimized for both businesses and individual users. DAO Management Tools: Create DAO management tools that streamline processes such as proposal submissions and voting.
Nevertheless, the examples above are only a few prominent use cases, and you can build a lot more with our Gnosis API!
Summary: Moralis’ Gnosis API – Easiest Way to Build Gnosis Chain Dapps
In today’s article, we introduced you to Moralis’ Gnosis API – the ultimate tool for building Gnosis chain dapps. With this tool, you can effortlessly get NFTs, wallet data, tokens, blockchain data, and much more with single lines of code. Consequently, when working with the Gnosis API, it has never been easier to build dapps on Gnosis Chain!
In addition to introducing you to the Gnosis API, we also showed you how to get the token balances of any wallet in three straightforward steps:
Get Your Moralis API KeyWrite a Script Calling the getWalletTokenBalances() EndpointExecute the Code
As such, if you have followed along in this article, you now know how to use the Gnosis API to fetch data from Gnosis Chain!
If you found this Gnosis API article interesting, consider checking out more Web3 content here on the blog. For example, learn how to build on Solana and EVM, or read our complete Blockchain API tutorial for more info on our premier Web3 development tools! Also, before leaving, make sure to sign up with Moralis if you want to leverage the full power of Gnosis Chain yourself!