Web3

Free Gnosis API for Creating Gnosis Chain Dapps

Do you wish to create Gnosis Chain dapps utilizing a free Gnosis API? If that’s the case, you’ve come to the fitting place! In at present’s article, we’ll introduce you to Moralis’ Gnosis API – the final word instrument for constructing decentralized functions (dapps) on Gnosis Chain. The Gnosis API options many outstanding endpoints you should use to fetch the whole lot from token costs to pockets balances with solely single traces of code. In case you’re wanting 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",
  "address": "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",
  "address": "0x88ad09518695c6c3712ac10a214be5109a655671"
});

In case you’re wanting 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’ll be able to arrange an account for free, and also you’ll immediately be capable of construct smarter and sooner on Gnosis Chain! 

Overview 

We’ll begin at present’s article by exploring the ins and outs of Gnosis Chain. From there, we’ll cowl a number 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 instrument for Gnosis improvement. Subsequent, we’ll dive into our Gnosis API tutorial, the place we’re going to point out you get the token balances of any pockets in three steps: 

  1. Get Your Moralis API Key
  2. Write a Script Calling the getWalletTokenBalances() Endpoint
  3. Execute 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 instrument! 

Moralis Gnosis API Marketing Banner

So, when you’re already conversant in Gnosis, be happy to skip the preliminary two sections and soar straight into the ”Moralis’ Gnosis API – Easiest Way to Build Gnosis Dapps” half. 

Nonetheless, when 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 completely 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 worldwide community of 160,000+ validators worldwide. The community’s various set of validators and deal with community-driven governance ensures that Gnosis Chain stays impartial in its operations.

Gnosis Logo in the shape of an owl's face

Moreover, Gnosis Chain makes use of an modern 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, alternatively, gives safety by way of Gnosis’ consensus-layer Gnosis Beacon Chain. Consequently, GNO is used for staking, protocol safety, and group governance. 

Along with the Ethereum sidechain, Gnosis hosts an intensive ecosystem of different merchandise. Two outstanding examples embody CoW and Protected. CoW, quick for ”coincidence of needs”, is a permissionless decentralized alternate (DEX) permitting customers to commerce ERC-20 tokens. Protected 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 strong playground permitting you, as a developer, to innovate and construct artistic Web3 initiatives. Nonetheless, why must you choose to construct on Gnosis Chain? To reply this query, let’s discover 5 outstanding advantages of this blockchain community: 

  • Swift Efficiency: With a formidable five-second block time, you’ll be able to expertise fast transaction confirmations.  
  • Globally Secured: With an intensive set of greater than 160,000 validators worldwide, Gnosis Chain is ready to supply excessive safety.
  • Value-Environment friendly: Lower your expenses by attaining environment friendly operations at simply $0.000099 per 100k fuel.
  • 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 most of the identical instruments you’d use for Ethereum improvement. 

Now, with an summary of the advantages of Gnosis Chain, let’s discover the best technique to construct dapps on the community! 

Moralis’ Gnosis API – Best Technique to Construct Gnosis Dapps

The simplest technique to construct on Gnosis Chain is to leverage Moralis’ Gnosis API. The Gnosis API from Moralis is an industry-leading instrument that lets you unlock the complete potential of Gnosis Chain. With the options of this interface, you’ll be able to effortlessly construct dapps sooner and extra effectively. In flip, you’ll save an abundance of improvement time and assets! 

Art image showing the Gnosis API title with endpoint components

So, why must you be part of a number of the largest names in Web3 and construct with Moralis? To reply this query, let’s discover a number 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 immediately from Gnosis Chain.
  • Absolutely Listed Information: Entry the totally listed and ready-to-use information on Gnosis Chain. 
  • Immediate Setup: Keep away from any hassles of preliminary setups and soar straight into improvement. 
  • Scalability: All of Morlis’ APIs are constructed to scale. Consequently, the Gnosis API will scale together with your initiatives, guaranteeing easy and hassle-free efficiency. 
  • Knowledgeable Assist: Entry world-class help from our staff of skilled blockchain specialists.
  • And far more! 

The Gnosis API suite consists of industry-leading interfaces, and within the following part, we’ll introduce you to a few outstanding examples!

Pockets API 

The Moralis Pockets API is the final word instrument 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 plenty of others. Moreover, this interface boasts an array of outstanding options, unparalleled scalability, and distinctive flexibility, making it stand out because the {industry}’s premier API for pockets information! 

Art image - Showing code for the Gnosis Wallet API

The Pockets API options many outstanding endpoints, and with solely single traces of code, you’ll be able to seamlessly fetch all tokens, NFTs, native tokens, transactions, and many others., and test the exercise of any pockets on Gnosis Chain. 

For example the accessibility of this instrument, 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",
  "address": "0x88ad09518695c6c3712ac10a214be5109a655671"
});

Because of the multi-chain capabilities of the Pockets API, you should use the identical instrument 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 enables you to seamlessly unlock the ability 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! 

Art illustration - showing code components and what you can build using the Gnosis Blockchain API

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 offers you a bunch of knowledge in regards to the block, together with a timestamp, hash, quantity, log blooms, the miner, fuel used, and far more.

To indicate you ways 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, similar to the Pockets API, the Blockchain API additionally helps a number of networks. Consequently, you should use this instrument to construct cross-chain appropriate dapps that combine sensible contract logs, occasions, tackle labels, and many others. 

Token API 

The Moralis Token API is the final word instrument for token information, with protection spanning all tokens on all main chains, together with Gnosis Chain, BNB Sensible Chain, Ethereum, Ploygon, and plenty of others! 

Title - Moralis Token API

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 many others., has by no means been simpler!

To spotlight the accessibility of the Token API, right here’s an instance of how you should use the getWalletTokenBalances() endpoint to get all token balances of a pockets:

const response = await Moralis.EvmApi.token.getWalletTokenBalances({
  "chain": "0x64",
  "address": "0x88ad09518695c6c3712ac10a214be5109a655671"
});

Additionally, since Moralis’ Token API helps all main chains, you should use this interface to construct cross-chain initiatives integrating token metadata, stats, transfers, and far more! 

Nonetheless, the three interfaces above are just some examples, and there’s much more to the Gnosis API suite. If you wish to discover all of the instruments and obtainable endpoints, try our Web3 API web page or the Web3 API documentation!

Gnosis API Tutorial: Methods to Get the Token Balances of any Pockets 

On this part, we’ll present an in-depth tutorial exhibiting you 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 simple steps: 

  1. Get Your Moralis API Key
  2. Write a Script Calling the getWalletTokenBalances() Endpoint
  3. Execute the Code

Nonetheless, you need to take care of a couple of important conditions earlier than you may get going! 

Stipulations 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, ensure you have the next prepared earlier than you proceed: 

Step 1: Get Your Moralis API Key 

The very first thing you’ll must name the Gnosis API is a Moralis API key. Consequently, begin by clicking on the ”Begin for Free” button on the prime proper to enroll with Moralis: 

Step 1 - Click on the "Start for Free" button to sign up using Moralis Gnosis API

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: 

Moralis Setting Page and the Gnosis API Key copy button

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 popular built-in improvement atmosphere, arrange a brand new venture, 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 some other configuration
  });

  const tackle = "0x88ad09518695c6c3712ac10a214be5109a655671";

  const chain = "0x64";

  const response = await Moralis.EvmApi.token.getWalletTokenBalances({
    tackle,
    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: 

Showing the code snippet and where to paste the Gnosis API key

Afterward, configure the tackle fixed by assigning it the tackle of the pockets from which you wish to question the token balances. What’s extra, guarantee that the chain const is ready to 0x64

Showing the address and chain parameters and modifications to make to build on Gnosis Chain

We then cross alongside each tackle and chain as parameters when calling the getWalletTokenBalances() endpoint: 

getWalletTokenBalances() endpoint example using the Gnosis Chain API

That’s it for the code; all that is still 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 venture: 

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 stability. It ought to look one thing like this:

[
  {
    token_address: '0xfd135b71c8dbb1c2bd052edafc9cba77dd2a7d69',
    image: 'xdai.firstchef.internet',
    identify: 'xdai.firstchef.internet',
    brand: null,
    thumbnail: null,
    decimals: 18,
    stability: '600000000000000000000000000',
    possible_spam: true
  },
  //...
[

Congratulations; you now know get all token balances of any pockets on Gnosis Chain! 

You’ll be able to observe the identical steps to name some other endpoint for Gnosis Chain. You merely must make minor configurations to the parameters and alter the endpoint throughout the second step! 

Gnosis API Use Circumstances 

Now that you understand how to fetch information from Gnosis Chain utilizing our API, let’s additionally take a look at three examples of what you’ll be able to construct utilizing this industry-leading instrument: 

  • Governance Platforms: Construct a community-driven decision-making platform that enables customers to take part in polls and form the way forward for your ecosystem. 
  • Pockets Platforms: Arrange your personal multi-sig pockets infrastructure like Protected, optimized for each companies and particular person customers. 
  • DAO Administration Instruments: Create DAO administration instruments that streamline processes akin to proposal submissions and voting.
Showing three Gnosis API Example Dapps

However, the examples above are just a few outstanding use instances, and you’ll construct much more with our Gnosis API!

Abstract: Moralis’ Gnosis API – Best Technique to Construct Gnosis Chain Dapps

In at present’s article, we launched you to Moralis’ Gnosis API – the final word instrument for constructing Gnosis chain dapps. With this instrument, you’ll be able to effortlessly get NFTs, pockets information, tokens, blockchain information, and far more with single traces of code. Consequently, when working with the Gnosis API, it has by no means been simpler to construct dapps on Gnosis Chain! 

Along with introducing you to the Gnosis API, we additionally confirmed you get the token balances of any pockets in three simple steps: 

  1. Get Your Moralis API Key
  2. Write a Script Calling the getWalletTokenBalances() Endpoint
  3. Execute the Code

As such, you probably have adopted alongside on this article, you now know use the Gnosis API to fetch information from Gnosis Chain! 

In case you discovered this Gnosis API article attention-grabbing, think about trying out extra Web3 content material right here on the weblog. For instance, learn to construct on Solana and EVM, or learn our full Blockchain API tutorial for extra data on our premier Web3 improvement instruments! Additionally, earlier than leaving, be sure to enroll with Moralis if you wish to leverage the complete energy of Gnosis Chain your self!

DailyBlockchain.News Admin

Our Mission is to bridge the knowledge gap and foster an informed blockchain community by presenting clear, concise, and reliable information every single day. Join us on this exciting journey into the future of finance, technology, and beyond. Whether you’re a blockchain novice or an enthusiast, DailyBlockchain.news is here for you.
Back to top button