Skip to content

Commit

Permalink
feat: add new category for examples
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyar committed Jul 27, 2023
1 parent 3fb673e commit b235fca
Show file tree
Hide file tree
Showing 6 changed files with 114 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/solidity-by-example/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"position": 0,
"label": "Solidity by example",
"link": {
"title": "Solidity by example",
"slug": "solidity-by-example",
"type": "generated-index"
}
}
9 changes: 9 additions & 0 deletions src/solidity-by-example/application/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"position": 2,
"label": "Application",
"link": {
"title": "Application",
"slug": "application",
"type": "generated-index"
}
}
8 changes: 8 additions & 0 deletions src/solidity-by-example/basic/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"position": 0,
"label": "Basic",
"link": {
"slug": "solidity-by-example/basic",
"type": "generated-index"
}
}
47 changes: 47 additions & 0 deletions src/solidity-by-example/basic/first-app.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
sidebar_position: 2
title: First Application
description: Specifies the compiler version of Solidity
---

Here is a simple contract that you can get, increment and decrement the count store in this contract.

```solidity
// SPDX-License-Identifier: MIT
pragma ever-solidity ^0.70.0;
contract Counter {
uint public count;
// Function to increment count by 1
function inc() public {
// This action is required to process external messages that bring no value
tvm.accept();
count += 1;
}
// Function to decrement count by 1
function dec() public {
// This action is required to process external messages that bring no value
tvm.accept();
// This function will fail if count = 0
count -= 1;
}
}
```

## Deploying the contract

```shell
npx everdev sol compile first-app.sol
npx everdev contract deploy first-app -v 100000000
```

## Interacting with the contract

```shell
npx everdev contract run first-app inc
npx everdev contract run-local first-app count
npx everdev contract run first-app dec
npx everdev contract run-local first-app count
```
32 changes: 32 additions & 0 deletions src/solidity-by-example/basic/hello-world.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
sidebar_position: 1
title: "Hello World"
description: Specifies the compiler version of Solidity
---

`pragma` specifies the compiler version of Solidity.


```solidity
// SPDX-License-Identifier: MIT
// compiler version must be greater than or equal to 0.70.0 and less than 0.71.0
pragma ever-solidity ^0.70.0;
contract HelloWorld {
string public greet = "Hello World!";
}
```

## Deploying the contract

```shell
npx everdev sol set --compiler 0.70.0
npx everdev sol compile hello-world.sol
npx everdev contract deploy hello-world -v 100000000
```

## Interacting with the contract

```shell
npx everdev contract run-local hello-world greet
```
9 changes: 9 additions & 0 deletions src/solidity-by-example/hack/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"position": 3,
"label": "Hack",
"link": {
"title": "Hack",
"slug": "hack",
"type": "generated-index"
}
}

0 comments on commit b235fca

Please sign in to comment.