Integrating with the Internet Computer ledger

Hello IC devs!

I want to talk to you all about a very important canister within the Internet Computer — "The Ledger Canister."

This single canister, The Ledger Canister, is basically a smart contract that holds accounts and transactions. These transactions either mint ICP utility tokens for accounts, transfer ICP tokens from one account to another, or burn ICP tokens, eliminating them from existence. The Ledger Canister maintains a traceable history of all transactions starting from its genesis or beginning state.

But at the end of the day… important to remember, it’s just another canister, no special magic.

To help explain its intent, we are releasing documentation on it, but I want to highlight the main take-aways:

1. The document has an explanation of the Ledger Canister’s functionality and intent — this is mostly prose.

2. There are two ways to interact with the Ledger Canister:

a. Standard messages via canister’s interface: Despite its big-sounding name, the Ledger Canister is just another canister so any one person or canister can interact with it by sending it messages using the canister’s interface. This is how we expect most people will interact with it as it is very lightweight. This interface is NOT in the docs (yet) — we are updating it soon.

b. Rosetta API: There are entities such as Exchanges that need to comply with lots of regulations. As a result, we built a way for entities to interact with Ledger Canister via the very common crypto standard of the Rosetta API (https://www.rosetta-api.org/). Using the Rosetta API and its client (GitHub - dfinity/rosetta-client) is in the documentation linked, but it is NOT how we expect most people to interact with Ledger Canister. To be frank, if you are wondering “should I use Rosetta API?” — the answer is likely “No.”

3. Many external partners have been helping kicking the tires on this doc and the Rosetta API implementation, so we are very grateful to them.

That’s it!

Without further ado…Take a read and help us improve! The Ledger Canister in the docs: Integrate with the Internet Computer ledger :: Internet Computer

Diego

27 Likes

Excellent news!

a. Standard messages via canister’s interface : Despite its big-sounding name, the Ledger Canister is just another canister so any one person or canister can interact with it by sending it messages using the canister’s interface. This is how we expect most people will interact with it as it is very lightweight. This interface is NOT in the docs (yet) — we are updating it soon.

What is the canister ID of this Ledger in the different networks? (so we could get the canister’s interface before the docs?)

will there be any faucet? :slight_smile:

Hey Diego

Is the ledger Canister really just another canister in every way or does it have some special privileges? Wondering how it gets around the 4gb limit.

Hi David,

Good question. The Ledger Canister is NOT deployed on Sodium yet but on one of the testnets, so there is no helpful canister ID (yet), as soon as it is deployed to Mercury and folks added there, we will let folks know.

Good question. The like Ledger Canister can scale itself . It is written in a way so that it can create new canisters as needed.

The Ledger Canister can do this is via custom code that the team wrote for the Ledger Canister but using the same APIs and primitives that would be available to any canister developer. No special secret APIs for doing this.

2 Likes

Very good to see this!

This canister will be open sourced, right? This will give us a standard interface for token transaction history, which can be consumed by DeFi apps and analytics platforms eg. block explorers.

10 Likes

What language is the ledger-canister written in? And will it be open source in that language? What kind of auto-scaling bigmap is used?

Hi folks,

The ledger canister is written in Rust. Stay tuned for more details re: open sourcing and implementation details!

6 Likes

Hi,

Would like to have an update on this, is the ledger
Standard messages available and can you provide a working app example to test and learn please?

It seems the interfaces and canister IDs are available here:

Very nice! Are there any UIs available yet?

Some questions on the ledger interface, specifically for integration with other canisters:

  • What is the difference between an AccountIdentifier and a Principal? The docs state:

Account identifiers are 32 bytes and are roughly the equivalent of the hash of a public key, optionally together with some additional sub-account specifier.

  • How do subaccounts work? Is there a max number of subaccounts per account? Can I transfer to a specific subaccount? Do canisters have subaccounts?
  • Why do methods end in _dfx? Would be cleaner without it
  • Is there a name for the minimum denomination of ICP, ie. 1 * 10^-8 ICP?
  • Is there any validation done on the memo field? Are we expected to just set it to our ingress message nonce?
  • How do we query for the suggested fee? What happens if we specify a fee that is too low?
  • How does a canister receive a notification?
  • How do I get the current BlockHeight?
3 Likes

ic/rs/rosetta-api/ledger_canister at master · dfinity/ic · GitHub :tada:

5 Likes

Is there any document yet? If not, can I have an example of how to transfer ICP token using Rosetta API?

I think there is some Rosetta documentation here: GitHub - dfinity/rosetta-client

1 Like

And the canisterIDs on mainnet:

1 Like

I am trying to get the Rosetta API working with the mainnet Ledger Canister but I get 403 errors. I’m using the following arguments with the Rosetta API:
-c ryjl3-tyaaa-aaaaa-aaaba-cai --ic-url https://ic0.app --mainnet

Did anybody successfully connect to the mainnet ledger canister with the Rosetta API?

1 Like

What is the advantage of the notify() mechanism of this canister over the ERC677 (for example) sendAndCall()? Is it cheaper to do it this way or what?

@wang I know you’ve been working on IC-compatible tokens for a while now, do you have any ideas why didn’t they stick with the classics?

Thanks in advance.

2 Likes

Good question, maybe @nomeata can enlighten us.

It seems like in order to create a canister from a canister, we need to send a transaction to the ledger and then notify with memo 0x41455243. Is there an example of this in Motoko?

2 Likes

can’t sync rosseta-api to mainnet…

$ docker run \
–interactive
–tty
–publish 8080
–rm
dfinity/rosetta-api --mainnet

then

ERROR [main] ic_rosetta_api::rosetta_server - Error in syncing blocks: InternalError(false, Some({“error_message”: String("In tip: HTTP Client: Request for https://rosetta.dfinity.network/api/v2/canister/ryjl3-tyaaa-aaaaa-aaaba-cai/query failed: Response { status: 403,