David Nasaw
David Nasaw

Reputation: 167

How to get idl from rust on-chain program of solana?

I have just started to work as Solana developer.
I have developed my own smart contract but I can't get idl even after building.
How can I call the contract function?

Upvotes: 1

Views: 2788

Answers (3)

Daniel Pavel
Daniel Pavel

Reputation: 13

Have you tried getting the IDL via anchor cli?

anchor idl fetch -o <out-file.json> <program-id>

Also, If you're using Typescript I find it convenient to generate the type for the IDL:

anchor idl type <idl-file.json> > <idl-type.ts>

You can read more in the anchor book

Hope it helps!

Upvotes: 0

Setmax
Setmax

Reputation: 1034

did you try anchor?

Anchor is a framework for Solana's Sealevel (opens new window)runtime providing several convenient developer tools.

  • Rust crates and eDSL for writing Solana programs

  • IDL (opens new window)specification

  • TypeScript package for generating clients from IDL

  • CLI and workspace management for developing complete applications

If you're familiar with developing in Ethereum's Solidity (opens new window), Truffle (opens new window), web3.js (opens new window)or Parity's Ink! (opens new window), then the experience will be familiar. Although the DSL syntax and semantics are targeted at Solana, the high level flow of writing RPC request handlers, emitting an IDL, and generating clients from IDL is the same.

Upvotes: -1

Yilmaz
Yilmaz

Reputation: 49182

Easiest way is use https://beta.solpg.io/. This is like Remix for solidity.

You write your contract, build and then export idl.

enter image description here

Upvotes: 1

Related Questions