Skip to content
This repository was archived by the owner on Mar 12, 2024. It is now read-only.

Commit 17c2cf5

Browse files
authored
chore: Sync with Gitbook
chore: Sync with Gitbook
2 parents 6c7fba5 + 3e89ace commit 17c2cf5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+68
-3482
lines changed
-292 KB
Binary file not shown.

.gitbook/assets/22_gnoscan.png

-327 KB
Binary file not shown.

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
# Gnoland Developer Portal
22

3-
Welcome to the Gnoland Developer Portal! 
3+
Welcome to the Gnoland Developer Portal!
44

55
The purpose of this guide is to invite new developers into the world of Gnolang, a new programming language powering the Gnoland blockchain, by providing all the resources you need to become a Gnolang expert.
66

77
_(This is an early-stage, in-progress draft. Your contributions are welcome. Please take a look at the_ [_contribution guidelines_](https://github.com/onbloc/gnoland-tutorials/blob/main/CONTRIBUTION.md)_.)_
88

99
You can read the docs in [Gitbook](https://onbloc.gitbook.io/gnoland-developer-portal/) or [GitHub](https://github.com/onbloc/gnoland-tutorials).
1010

11-
1211
## Table of Contents
1312

1413
* Introduction to Gnoland

docs/building-a-realm/deploy-and-call-realms.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Deploy and Call Realms
22

3-
There are two methods of deploying and calling realms. 
3+
There are two methods of deploying and calling realms.
44

55
1. With the blockchain: You can use the subcommands of [`gnokey`](../cli/gnokey.md) such as [`addpkg`](../cli/gnokey.md#subcommands), to deploy a realm to the Gnoland blockchain, and [`maketx call`](../cli/gnokey.md#call), to call available realms in the Gnoland blockchain.
66
2. Without a blockchain: You can use [`gno`](../cli/gno.md), which allows you to use the GnoVM without a blockchain in a local environment. This method is fast and allows you to use development patterns such as TDD. However, it does not facilitate the capability for external parties to participate in testing since it's done locally.

docs/building-a-realm/overview.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ A realm refers to a specific instance of a smart contract that can be written in
44

55
Before we dive in, let's first study the differences between realms and packages.
66

7-
#### ****[**Realms**](https://github.com/gnolang/gno/tree/master/examples/gno.land/r)****
7+
#### [**Realms**](https://github.com/gnolang/gno/tree/master/examples/gno.land/r)
88

99
* Smart contracts in Gnolang.
1010
* Realms are stateful.
1111
* The default import path is `gno.land/r/~~~`.
1212
* Each realm has the capability to publicly export the function `Render(path string) string`, which performs rendering when passed a valid markdown as a parameter for the specified `path`.
1313

14-
#### ****[**Packages**](https://github.com/gnolang/gno/tree/master/examples/gno.land/p/demo)****
14+
#### [**Packages**](https://github.com/gnolang/gno/tree/master/examples/gno.land/p/demo)
1515

1616
* A unit that contains functionalities and utilities that can be used in realms.
1717
* Packages are stateless.

docs/building-a-realm/realm-examples/first.gno.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,6 @@ func ImpossibleInc() {
5454

5555
Let's break down the code by each segment.
5656

57-
58-
5957
```go
6058
var myVar = 1
6159

@@ -76,8 +74,6 @@ The code block above displays the variable & constant declaration code (and 2 fu
7674

7775
As a result, once the code above is executed, the `initlVar` variable with only a declared data type, but without an initial value, is assigned with a value of `1000`.
7876

79-
80-
8177
```go
8278
func get() int {
8379
return myVar
@@ -116,8 +112,6 @@ The `Dec()` function decrements the value of `myVar`. However, as it does not po
116112

117113
The `ImpossibleInc()` function at the end results in an error as it attempts to modify the value of the constant.
118114

119-
120-
121115
### Test Code
122116

123117
```go

docs/building-a-realm/realm-examples/foo.gno.md

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ We first import packages and realms that we'll be using in the `foo` realm. Then
3030

3131
> **Note:** The `admin` address will be the only address that can can mint or burn tokens.
3232
33-
34-
3533
```go
3634
func assertIsAdmin() error {
3735
caller := std.GetOrigCaller()
@@ -44,8 +42,6 @@ func assertIsAdmin() error {
4442

4543
The `assertIsAdmin()` function implements a logic to check if the caller of the admin-only function is the `admin` address. This concept is similar to the `require` or `modifer` in Solidity.
4644

47-
48-
4945
```go
5046
func init() {
5147
foo = grc20.NewAdminToken("Foo Token", "FOO", 4)
@@ -61,8 +57,6 @@ The `init()` function resets the package and creates the `foo` token with the fo
6157

6258
Then, the function mints 100 `foo` tokens to the `admin` address.
6359

64-
65-
6660
```go
6761
func Mint(address users.AddressOrName, amount uint64) error {
6862
if err := assertIsAdmin(); err != nil {
@@ -83,8 +77,6 @@ func Burn(address users.AddressOrName, amount uint64) error {
8377

8478
The `Mint` function and the `Burn` function respectively handles minting and burning of tokens. Both functions verify that the caller is the admin using the `assertIsAdmin()` function declared above.
8579

86-
87-
8880
```go
8981
func TotalSupply() uint64 {
9082
return foo.TotalSupply()
@@ -156,11 +148,11 @@ Other functions implement the specifications of ERC20 with 2 additional function
156148

157149
`FaucetWithoutAdmin`: Mints 200 `foo` tokens to an address (public).
158150

159-
`Allowance`: Returns the amount `owner`'s tokens that the `spender` can transfer on behalf of the `owner`. 
151+
`Allowance`: Returns the amount `owner`'s tokens that the `spender` can transfer on behalf of the `owner`.
160152

161153
`Approve`: Grants the `spender` with the authority to send a defined amount of `caller`'s `foo` tokens on behalf of the `caller`.
162154

163-
TransferFrom: The `spender` sends `owner`'s tokens on behalf of the `owner`. 
155+
TransferFrom: The `spender` sends `owner`'s tokens on behalf of the `owner`.
164156

165157
####
166158

@@ -295,9 +287,7 @@ func assertGRC20Balance(t *testing.T, addr users.AddressOrName, expectedBal uint
295287
}
296288
```
297289

298-
> **Tip:** the `users` realm enables users to register addresses with usernames([example](https://onbloc.gitbook.io/gnoland-developer-portal/tutorials/interact-with-gnoland#register-as-a-user)) on `/r/demo/users` for simplicity and convenience. 
299-
300-
290+
> **Tip:** the `users` realm enables users to register addresses with usernames([example](https://onbloc.gitbook.io/gnoland-developer-portal/tutorials/interact-with-gnoland#register-as-a-user)) on `/r/demo/users` for simplicity and convenience.
301291
302292
Let's assume that 3 addresses have been registered as users as the following:
303293

docs/building-a-realm/realm-examples/foo721.gno.md

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ var (
2626

2727
```
2828

29-
The code imports libraries, packages, and realms that it needs for implementation. Then, it initializes two variables to define the `admin` address, set the name of the NFT as `FooNFT`, its symbol as `FNFT`.
30-
31-
29+
The code imports libraries, packages, and realms that it needs for implementation. Then, it initializes two variables to define the `admin` address, set the name of the NFT as `FooNFT`, its symbol as `FNFT`.
3230

3331
```go
3432
func assertIsAdmin(address std.Address) {
@@ -58,8 +56,6 @@ func Burn(tid grc721.TokenID) {
5856

5957
The functions contained in the code above ensure that only the `admin` address has access to minting and burning of tokens.
6058

61-
62-
6359
```go
6460
func init() {
6561
mintNNFT(admin, 10)
@@ -76,15 +72,13 @@ func mintNNFT(owner std.Address, n uint64) {
7672

7773
The `init` function above mints 10 NFT tokens to the admin address. You can see from the mint function that it takes the address to receive the tokens and the amount of tokens to mint as arguments.
7874

79-
80-
8175
The logic of minting an NFT is more complex compared to that of `grc20`, due to the characteristics of NFT as follows:
8276

8377
* All NFTs are identified by a unique uint256 `TokenID` value.
8478
* The `ID` cannot be modified as long as the contract is functional.
8579
* A common practice of numbering IDs is to start from 0 and increase it by 1 in sequential order.
8680

87-
For example, If we want to mint NFTs from a contract, we need to know the number of NFTs minted so far from the contract, and specify `TokenID` which starts minting new NFTs. 
81+
For example, If we want to mint NFTs from a contract, we need to know the number of NFTs minted so far from the contract, and specify `TokenID` which starts minting new NFTs.
8882

8983
Let's assume there's an NFT contract that:
9084

@@ -93,8 +87,6 @@ Let's assume there's an NFT contract that:
9387

9488
And, if we want to mint 10 NFTs, `TokenID` will be `10`\~`19`.
9589

96-
97-
9890
```go
9991
func BalanceOf(user users.AddressOrName) uint64 {
10092
balance, err := foo.BalanceOf(user.Resolve())
@@ -155,12 +147,10 @@ Other functions are defined in the grc721 specification, each with the following
155147
* `OwnerOf`: Checks the owner address of a token, specified by its `id`.
156148
* `IsApprovedForAll`: Checks if all tokens of the `owner` has been approved for the `operator`.
157149
* `GetApproved`: Checks the address of the operator that's been approved of a token, specified by its `id`.
158-
* `Approve`: Approves a token owned by the `caller` to [a ](#user-content-fn-1)[^1]user. The token is specified by its `id`.
150+
* `Approve`: Approves a token owned by the `caller` to a user. The token is specified by its `id`.
159151
* `SetApprovalForAll`: Approves all tokens owned by the owner to a user.
160152
* `TransferFrom`: Transfers a token from the `from` address to the `to` address. The token is specified by its `id`.
161153

162-
163-
164154
### Test Code
165155

166156
```go
@@ -265,5 +255,3 @@ func shouldNoPanic(t *testing.T, f func()) {
265255
f()
266256
}
267257
```
268-
269-
[^1]:

docs/building-a-realm/realm-examples/hello.gno.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,6 @@ Functions that make changes to the state must have a subject for change, hence m
100100

101101
This method involves seemingly fewer options compared to `gnokey maketx call` method. However, passing the argument can be quite confusing: the realm path that exposes the `Render()` function must be placed in the `--data` option, and the arguments in a new line (`\n`).
102102

103-
104-
105103
If we return to our realm code, we can see that the other function, `Hello()`, also doesn't cause any state changes to the blockchain.
106104

107105
Any other function besides `Render()` can be invoked with `gnokey query vm/qeval`.

docs/building-a-realm/realm-examples/realm.gno.md

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
The `realm` realm provides a guide on how to import packages in a test environment (`gno`) and the production environment (`gnokey addpkg`) along with precautions to note.
44

5-
6-
75
First, let's write a test package:
86

97
```go
@@ -119,32 +117,22 @@ func TestGetPrivateVar(t *testing.T) {
119117

120118
<figure><img src="../../../.gitbook/assets/gor_04_02_gnodev.png" alt=""><figcaption></figcaption></figure>
121119

122-
We can confirm that the test has been successfully passed in the test environment using `gno`.&#x20;
123-
124-
120+
We can confirm that the test has been successfully passed in the test environment using `gno`.
125121

126122
<figure><img src="../../../.gitbook/assets/gor_04_03_realm_addpkg.png" alt=""><figcaption></figcaption></figure>
127123

128124
The package gets added successfully in the production environment.
129125

130-
131-
132126
<figure><img src="../../../.gitbook/assets/gor_04_04_render_call.png" alt=""><figcaption></figcaption></figure>
133127

134128
Calling `Render()` and `GetPublicVar()` using the `gnokey maketx call` also works as expected.
135129

136-
137-
138130
<figure><img src="../../../.gitbook/assets/gor_04_06_call_get_private.png" alt=""><figcaption></figcaption></figure>
139131

140132
However, unlike the results in `gno`, we run into an issue when calling the `getPrivateVar()` function using the `gnokey maketx call` command in the production environment.
141133

142-
143-
144134
<figure><img src="../../../.gitbook/assets/gor_04_07_query_get_private.png" alt=""><figcaption></figcaption></figure>
145135

146136
On the other hand, calling the `getPrivateVar()` function using the `gnokey query vm/qeval` command works successfully.
147137

148-
149-
150138
> **Note:** As of testnet3, we have run into unexpected results when using access modifiers with `gno`, `maketx`, and `query`. We suspect the cause to be one of the following: GnoVM, Gnokey Query, or gno. For now, we can get around this error by changing the lowercase to the uppercase to publicly access the functions. We will update this section once we determine the cause of this phenomenon.

0 commit comments

Comments
 (0)