Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update json-rpc.md to make Devnet the default #4012

Merged
merged 4 commits into from
Aug 16, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 22 additions & 18 deletions doc/src/build/json-rpc.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,29 @@
---
title: Local RPC Server & JSON-RPC API Quick Start
title: RPC Server & JSON-RPC API Quick Start
---

Welcome to the Sui RPC server quick start.
Welcome to the guide for making remote procedure calls (RPC) to the Sui network. This document walks you through connecting to Sui and using the Sui JSON-RPC API to interact with the Sui network. Use the RPC layer to test your dApps, sending their transactions onto the [Sui validators](../learn/architecture/validators.md) for verification.

This document walks you through setting up your own local Sui RPC Server and using the Sui JSON-RPC API to interact with a local Sui network. This guide is useful for developers interested in Sui network interactions via API. For a similar guide on Sui network interactions via CLI, refer to the [Sui CLI client](cli-client.md) documentation.
This guide is useful for developers interested in Sui network interactions via API and should be used in conjunction with the [SuiJSON format](sui-json.md) for aligning JSON inputs with Move Call arguments.

For a similar guide on Sui network interactions via CLI, refer to the [Sui CLI client](cli-client.md) documentation.

## Local RPC server setup
## Set up RPC server
Follow the instructions to [install Sui binaries](install.md).

### Start local Sui network
Follow the instructions to [create](cli-client.md#genesis) and [start](cli-client.md#starting-the-network) the Sui network.
### Connect to Sui network

#### Remote Devnet
Simply [connect to the Sui Devnet](../explore/devnet.md) to start making RPC calls to our remote server, build on top of Sui.

#### Local Sui Network
Alternatively, to [contribute](../contribute/index.md) to Sui itself, you may follow the instructions to [create](cli-client.md#genesis) and [start](cli-client.md#starting-the-network) a local Sui network.

The genesis process will create a `gateway.yaml` configuration file that will be used by the RPC server.

### Start local RPC server
### Start RPC server

Use the following command to start a local server:
Use the following command to start an RPC server:
```shell
$ rpc-server
```
Expand All @@ -38,15 +45,15 @@ Export a local user variable to store the hardcoded hostname + port that the loc
export SUI_RPC_HOST=http://127.0.0.1:5001
```

## Sui software development kits
## Use Sui software development kits

You can sign transactions and interact with the Sui network using any of the following:

* [Sui Rust SDK](rust-sdk.md), a collection of Rust language JSON-RPC wrapper and crypto utilities.
* [Sui TypeScript SDK](https://github.com/MystenLabs/sui/tree/main/sdk/typescript) and [reference files](https://www.npmjs.com/package/@mysten/sui.js).
* [Sui API Reference](https://docs.sui.io/sui-jsonrpc) for all available methods.

## Sui JSON-RPC examples
## Follow Sui JSON-RPC examples

In the following sections we will show how to use Sui's JSON-RPC API with
the `curl` command. See the [Sui API Reference](https://docs.sui.io/sui-jsonrpc) for the latest list of all available methods.
Expand All @@ -61,8 +68,8 @@ curl --location --request POST $SUI_RPC_HOST \
--data-raw '{ "jsonrpc":"2.0", "method":"rpc.discover","id":1}'
```

### Transfer Object
#### 1, Create an unsigned transaction to transfer a Sui coin from one address to another:
### Transfer object
#### 1, Create an unsigned transaction to transfer a Sui coin from one address to another
```shell
curl --location --request POST $SUI_RPC_HOST \
--header 'Content-Type: application/json' \
Expand Down Expand Up @@ -99,7 +106,7 @@ You will see output resembling:
2022-04-25T18:50:06.031925Z INFO sui::sui_commands: Signature : 6vc+ku0RsMKdky8DRfoy/hw6eCQ3YsadH6rZ9WUCwGTAumuWER3TOJRw7u7F4QaHkqUsIPfJN9GRraSX+N8ADQ==
```

#### 3, Execute the transaction using the transaction data, signature and public key.
#### 3, Execute the transaction using the transaction data, signature and public key
```shell
curl --location --request POST $SUI_RPC_HOST \
--header 'Content-Type: application/json' \
Expand Down Expand Up @@ -130,7 +137,8 @@ be owned by the address represented by `{{owner_address}}`.

### Invoke Move functions

#### 1, Execute a Move call transaction by calling the specified function in
#### 1, Execute a Move call transaction
Execute a Move call transaction by calling the specified function in
the module of a given package (smart contracts in Sui are written in
the [Move](move/index.md) language):

Expand Down Expand Up @@ -235,7 +243,3 @@ Below you can see a truncated sample output of [sui_publish](#sui_publish). One
...
}
```

## Connect to remote JSON-RPC server

Employ alternative ways of working with Sui's JSON-RPC API. Connect to [Sui Devnet](../explore/devnet.md), [Join Incentivized Testnet](https://sui.io/resources-sui/announcing-sui-incentivized-testnet/) and soon Mainnet!