> For the complete documentation index, see [llms.txt](https://onegate.gitbook.io/onegate/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://onegate.gitbook.io/onegate/nep-21-dapi-for-n3/summary.md).

# Summary

NEP-21 proposes a common browser API for N3 dApps and external wallet providers. It lets a dApp obtain a wallet provider, inspect wallet metadata, read accounts, request signatures, invoke contracts, relay transactions, and query selected chain data.

This documentation is written for two readers:

| Reader           | What to look for                                                         |
| ---------------- | ------------------------------------------------------------------------ |
| dApp developers  | How to obtain a provider and call the standard methods.                  |
| Wallet providers | What shape the provider object, methods, events, and errors should have. |

The API pages follow the general style of wallet dAPI documentation: each method has a short description, parameters, return value, possible errors, and an example where useful. The content itself follows the current NEP-21 proposal.

## How dApps Get a Provider

NEP-21 providers are obtained through browser events.

Wallets announce a provider by dispatching `Neo.DapiProvider.ready`:

```ts
window.dispatchEvent(new CustomEvent("Neo.DapiProvider.ready", {
  detail: {
    provider,
  },
}));
```

dApps listen for this event and read the provider from `event.detail.provider`:

```ts
window.addEventListener("Neo.DapiProvider.ready", (event) => {
  const provider = (event as CustomEvent).detail.provider;
  console.log(provider.name);
});
```

A dApp may also request a provider by dispatching `Neo.DapiProvider.request`:

```ts
window.dispatchEvent(new CustomEvent("Neo.DapiProvider.request", {
  detail: {
    version: "1.0",
  },
}));
```

Wallets that support the requested version should respond by injecting or announcing a compatible provider.

## Provider Metadata

The provider exposes wallet metadata as properties.

```ts
const info = {
  name: provider.name,
  version: provider.version,
  dapiVersion: provider.dapiVersion,
  compatibility: provider.compatibility,
  connected: provider.connected,
  network: provider.network,
  supportedNetworks: provider.supportedNetworks,
  icon: provider.icon,
  website: provider.website,
  extra: provider.extra,
};
```

If the provider supports NEP-21, `compatibility` should include `"NEP-21"`.

## Minimal dApp Example

```ts
let provider: any;

window.addEventListener("Neo.DapiProvider.ready", (event) => {
  provider = (event as CustomEvent).detail.provider;
});

window.dispatchEvent(new CustomEvent("Neo.DapiProvider.request", {
  detail: { version: "1.0" },
}));

// After a provider is available:
const accounts = await provider.getAccounts();
const count = await provider.getBlockCount();

console.log(accounts, count);
```

## Pages

| Page                                                                        | Contents                                             |
| --------------------------------------------------------------------------- | ---------------------------------------------------- |
| [API Reference](broken://pages/2323eefb05dcb926e8199355efcf8dace8098757)    | Provider discovery, properties, events, and methods. |
| [Types and Errors](broken://pages/93bdf43965624a52688629e13c09520618bfa548) | Shared TypeScript-style types and error codes.       |

## Network Values

| Network | Magic       |
| ------- | ----------- |
| MainNet | `860833102` |
| TestNet | `894710606` |

## Source

* [NEP-21 proposal PR #145](https://github.com/neo-project/proposals/pull/145)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://onegate.gitbook.io/onegate/nep-21-dapi-for-n3/summary.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
