Skip to content

Commit afd5f65

Browse files
authored
feat: add docs about sonaium network (#77)
<!-- Generated by sourcery-ai[bot]: start summary --> ## Summary by Sourcery Introduce detailed documentation for the Soneium network, covering various aspects such as state machines, token standards (ERC-20 and ERC-721), node connectivity, integration tools, and foundational network information. Documentation: - Add comprehensive documentation for Soneium network, including guides on state machines, ERC-20 and ERC-721 tokens, node connection, integration tools, and network basics. <!-- Generated by sourcery-ai[bot]: end summary --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced comprehensive documentation for Soneium, covering its blockchain ecosystem, node types, connection methods, network statistics, and integration tools. - Added guides for creating ERC-20 and ERC-721 tokens, including deployment instructions and metadata management. - Implemented a state machine framework for smart contracts, detailing state transitions and history tracking. - Organized documentation with a new category for Soneium for better navigation. - **Documentation** - Enhanced user guidance with detailed instructions and examples for developers interacting with the Soneium platform. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent f388632 commit afd5f65

File tree

9 files changed

+991
-0
lines changed

9 files changed

+991
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# The basics
2+
3+
Soneium is a next-generation blockchain ecosystem designed to invoke emotion and empower creativity. It was founded by Sony Group Corporation, a global technology leader, and Startale, a Web3 innovator. Soneium stands as a versatile, general-purpose blockchain ready to serve diverse needs across all verticals and support users globally.
4+
5+
Soneium's L2 tech stack is based on the OP Stack technology from Optimism, as it plans to join the Superchain, a network of interconnected blockchains.
6+
7+
Soneium operates as a public Ethereum layer 2 solution that combines the security and decentralization of Ethereum with enhanced scalability and user-friendliness. It is integrated into the Superchain network, which uses Optimism's OP Stack technology to expand Ethereum's capacity. Soneium supports a wide range of applications, offering a comprehensive development environment with tools and resources tailored for both developers and users, all while aiming to make blockchain technology an integral part of everyday life.
8+
9+
## Testnet
10+
11+
Currently, Soneium is in its development phase and only offers a testnet. SettleMint supports the **Soneium Minato** testnet.
12+
13+
The Testnet is an instance of the blockchain used for testing and experimentation. The coins used in the Testnet have no real value, mitigating the risk of losing real funds. This allows developers and users to interact with the network, test applications, and experiment with features without financial risk.
14+
15+
You can consider the Testnet as a prototype environment, similar to a staging server in traditional software development.
16+
17+
## Future Mainnet
18+
19+
While Soneium does not have a mainnet at this time, it is anticipated that a mainnet will be launched in the future. The mainnet will be the primary public Soneium production blockchain where real-value transactions will occur. Each transaction on the future mainnet will likely require payment of a transaction fee, payable in the native coin SON.
20+
21+
## Consensus mechanism
22+
23+
Soneium employs an efficient consensus algorithm designed for high performance and security. While specific details about Soneium's consensus mechanism may not be publicly available, it likely shares some characteristics with other modern blockchain consensus protocols:
24+
25+
1. **High Throughput**: The consensus mechanism is designed to process a large number of transactions quickly.
26+
2. **Fast Finality**: Transactions on the Soneium network are expected to be confirmed rapidly.
27+
3. **Scalability**: The system is built to handle increasing transaction volumes efficiently.
28+
4. **Byzantine Fault Tolerance**: The protocol aims to achieve consensus even if some nodes in the network act maliciously or fail.
29+
30+
The Soneium consensus algorithm is being developed to provide a robust foundation for decentralized applications, offering a balance of speed, security, and decentralization.
31+
32+
For the most up-to-date and detailed information about Soneium, including any announcements about the future mainnet launch, please refer to the official Soneium documentation or website.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Node types
2+
3+
All nodes running in SettleMint are configured to be **archive nodes**, meaning they all include all previous states of a given blockchain since its origin.
4+
5+
[Learn here how to interact with your Soneium node.](3_soneium-connect-to-a-node.md)
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# Connect to a node
2+
3+
For a software application to interact with a blockchain (e.g. by sending transactions/data to the network, or even just by reading data), it must connect to a node. This section describes how to connect to your Soneium node.
4+
5+
## Backend APIs
6+
7+
Once a node has been deployed on an EVM (Ethereum Virtual Machine) compatible network, such as Soneium Minato, it can be accessed by different endpoints such as JSON-RPC, JSON-WS or GraphQL. You can connect to your already deployed node using these 3 most common endpoints.
8+
9+
### JSON-RPC
10+
11+
JSON-RPC, is a stateless, light-weight remote procedure call (RPC) protocol. Primarily, the specification defines several data structures and the rules around their processing. By default, the version of the JSON-RPC protocol needs to be 2.0, and you need to provide the node ID as well as a method and parameters.
12+
13+
There are different kinds of methods that can be used: ADMIN methods, DEBUG methods, ETH methods etc.
14+
15+
If you want to correctly connect to your node, you need to respect the right structure for the request, which is always the same:
16+
17+
```json
18+
{
19+
"jsonrpc":"2.0"
20+
"Id": nodeId
21+
"method":"methodName"
22+
"params":{
23+
}
24+
}
25+
```
26+
27+
If you want to connect to a node deployed on the SettleMint platform, go to the **Connect** tab on the **Node detail page** in the **Blockchain nodes** section of your application. Select JSON-RPC or any other endpoint and click **Try it out**. You will then be redirected to a new tab where you will be able to test different methods as well as the related Curl command line.
28+
29+
### JSON-WS
30+
31+
To make RPC requests over WebSockets, you can use wscat, which is by definition a Node.js based command-line tool. First you will need to connect to your node’s WebSocket server using wscat, as follows: `wscat -c ws://<JSON-RPC-ws-endpoint:port>`. All the credentials are provided in the **Connect** tab on the **Node detail page** in the **Blockchain nodes** section of your application. After you have established a connection, the terminal should display a '>' prompt. You will then be able to send individual requests as a JSON data package, as above, for instance:
32+
33+
```json
34+
{
35+
"jsonrpc":"2.0"
36+
"Id": 1
37+
"method":"eth_blockNumber"
38+
"params":{
39+
}
40+
}
41+
```
42+
43+
### GraphQL
44+
45+
GraphQL is a query language and server-side runtime for API’s. It is designed to make APIs fast, flexible, and developer-friendly.
46+
We have a GraphQL interface that can be used with many different queries. These queries can be tested out in our GraphQL playground. You can also test out the different graphql queries with cURL, those request would look like this:
47+
48+
```bash
49+
curl -X POST -H "Content-Type: application/json" -H “x-auth-token: <AUTH_TOKEN>” --data
50+
'{ "query": "{syncing{startingBlock currentBlock highestBlock}}"}' http://<DOMAIN>.settlemint.com/graphql
51+
```
52+
53+
If you want to connect to a node deployed on the SettleMint platform, go to the **Connect** tab on the **Node detail page** in the **Blockchain nodes section** of your application. Select Graphql and click **Try it out**. This will bring you to the GraphQL playground where you can use all the different queries.
54+
55+
## Javascript API
56+
57+
If you do not want to use the above endpoints to connect to your node, it is possible to use plain Javascript. Several convenience libraries exist within the different ecosystem which makes connection much easier. With these libraries, developers around the world can write one-line methods to easily initiate requests (still under the hood) that interact with Ethereum or any other EVM compliant network. Note that some libraries might be available for Ethereum but not for the other networks.
58+
59+
These libraries are very helpful and abstract away much of the complexity of interacting directly with your node. Most also provide useful and straightforward functions such as converting ETH to Gwei, so that you can spend less time dealing with decimal issues and more time on the functionality of your underlying application.
60+
61+
One of the most commonly used libraries, Ethers, is extremely easy to use for signing transactions, sending tokens etc. For example:
62+
63+
```typescript
64+
// If you don't specify a //url//, Ethers connects to the default
65+
// (i.e. ``http:/\/localhost:8545``)
66+
const provider = new ethers.providers.JsonRpcProvider();
67+
68+
// The provider also allows signing transactions to
69+
// send ether and pay to change state within the blockchain.
70+
// For this, we need the account signer...
71+
const signer = provider.getSigner();
72+
```
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Network stats
2+
3+
The dashboard gives you an overview of the following stats for the network:
4+
5+
## Best block
6+
7+
Shows the "heaviest" block in terms of cumulative difficulty. In other words, the latest block number of the longest valid chain.
8+
9+
## Last block
10+
11+
Shows the time, in seconds, since the last block was mined. This value is a good indicator of whether the network is still up and running. A value noticeably above the average time between blocks indicates that the network is no longer mining blocks.
12+
13+
## Average block time
14+
15+
Shows the average time, in seconds, it takes for the network to mine a new block.
16+
17+
## Nodes
18+
19+
Shows the number of nodes in this network.
20+
21+
## Transactions
22+
23+
Shows the number of transactions for the last 10 blocks.
24+
25+
## Gas usage
26+
27+
Shows the amount of gas spent for the last 10 blocks.
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Smart contracts IDE
2+
3+
The SettleMint IDE is the only tool you need to edit the smart contract set template you have selected, or **write** your own brand **new** smart contracts. The programming language used for your Soneium smart contracts is Solidity.
4+
5+
## Using the IDE
6+
7+
When you open the IDE, you land in an instance of Visual Studio Code similar to the image below.
8+
9+
![ide](../../../static/img/blockchain-guide/IDE.png)
10+
11+
On the left, in the **“Explorer”** panel, you can see all the folders and files related to the smart contract set.
12+
13+
The smart contract files are located in the **“contracts”** folder. You can edit them, or use them as they are if the template fits all your needs.
14+
15+
The **“deploy”** folder contains the scripts that enable the deployment of the smart contract set on the blockchain. You might have to edit these scripts if you add new arguments to the constructor of your smart contract.
16+
17+
The **“test”** folder contains a script that lets you test the functionalities of your smart contracts. You can add new ones if you edit the template. Do not hesitate to go through the test cases as they provide valuable information on how to use your smart contracts.
18+
19+
The **subgraph** folder holds all the files needed to index your smart contract using the Graph protocol.
20+
21+
## Scripts
22+
23+
Several scripts are defined in `package.json` to help you use the smart contract set:
24+
25+
- **lint** to lint your smart contracts, i.e. find the stylistic errors.
26+
- **compile** to compile your smart contracts.
27+
- **test** to run the test script in the “test” folder.
28+
- **smartcontract:deploy** to deploy the smart contract set on the blockchain.
29+
- **smartcontract:deploy:reset** to deploy from scratch after a first deployment.
30+
- **graph:config** to create the middleware configuration file.
31+
- **graph:compile** to compile the middleware files.
32+
- **graph:codegen** to create the middleware schema.
33+
- **graph:build** to build the middleware.
34+
- **graph:deploy** to deploy the middleware.
35+
- **graph:all** to execute all the graph scripts in one command.
36+
37+
:::warning Note
38+
39+
To execute the scripts related to the Graph middleware, you need a middleware instance in your app.
40+
41+
:::
42+
43+
You can execute these scripts in the terminal integrated with the IDE by running `yarn name-of-script`.
44+
For example, to run the `smartcontract:deploy` task using the terminal, open a new terminal (ctrl + shift + \`) and run the command`yarn smartcontract:deploy`.
45+
46+
## Private key
47+
48+
To be able to deploy your smart contract set on the blockchain you need to have a private key enabled on your node to sign the transaction, and you need to fund this key with Ether to cover the cost for the transaction. You can create a private key and fund it in the **Private keys section** of your application. [More about private keys.](../../using-platform/17_private-keys.md)
49+
50+
## Template library
51+
52+
Every instance of the IDE contains a set of pre-built smart contract templates. These templates are easily customizable to match your specific use case. [Discover the smart contract set templates for Soneium.](../12_Soneium/Template-library/1_soneium-erc-20.md)
53+
54+
## Generative AI plugin
55+
56+
The integration of an OpenAI GPT plugin into the Smart Contract IDE of the SettleMint platform brings forth significant advantages for the fast development of new smart contracts. Generative AI technology empowers developers by providing them with automated code suggestions, smart contract templates, and code completion capabilities. This accelerates the development process by reducing manual effort and improving code efficiency.
57+
58+
Additionally, the interactive debugging and explanation features offered by the GPT plugin greatly benefit developers of all skill levels. Beginners can leverage the plugin’s explanations to understand complex concepts, improve their coding skills, and gain insights into best practices. Experienced developers can utilize the debugging features to quickly identify and resolve issues, leading to more robust and error-free smart contracts.
59+
60+
Overall, the integration of the OpenAI GPT plugin into the SettleMint platform’s Smart Contract IDE combines the power of generative AI and interactive debugging to enhance productivity, code quality, and learning opportunities for developers in the blockchain space.
61+
62+
You can find this plugin in the sidebar (magic lamp icon), in context menu and the action panel. The first time you use the plugin you will get asked for an OpenAI API key. Depending on your OpenAI API access you can use the default GPT 3.5 model or the GPT 4 model which is slower, but more accurate. Check out the settings in the IDE to configure this and other settings (like using your own Azure GPT service)
63+
64+
Here are some prompts to get you started:
65+
66+
- Write a Solidity ERC20 token representing a bond, based on OpenZeppelin. Include a bond repayment and coupon payments.
67+
- Write a Solidity ERC721 token representing real estate, based on OpenZeppelin and allow fractional ownership of this NFT in the form of ERC20 tokens.
68+
- Write The Graph indexing code that indexes an ERC721 token on the Ethereum Mainnet.
69+
70+
<iframe width="560" height="315" src="https://www.youtube-nocookie.com/embed/-e4weLqbYjk" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>

0 commit comments

Comments
 (0)