Skip to content

Commit

Permalink
Merge pull request #107 from babowsk1/patch-1
Browse files Browse the repository at this point in the history
Patch 1
  • Loading branch information
VenomBlockchain authored Apr 18, 2024
2 parents 8e2847d + c84c278 commit 7c4124b
Show file tree
Hide file tree
Showing 18 changed files with 69 additions and 79 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ npx locklift init --path my-smv
As you previously read, we need to implement two smart contracts. There are no external dependencies for this guide. Start with `Vote` contract. We have a pretty clean state and constructor without something unusual

```solidity title="Vote.sol" showLineNumbers
pragma ever-solidity >= 0.61.2;
pragma ever-solidity >= 0.62.0;
pragma AbiHeader expire;
pragma AbiHeader pubkey;
Expand Down Expand Up @@ -51,7 +51,7 @@ contract Vote {
Next function we need - `deployBallot`. It realizes the popular "deploy contract from contract" mechanic well-described [here](https://github.com/tonlabs/TON-Solidity-Compiler/blob/master/API.md#deploy-contract-from-contract). We should just use `tvm.buildStateInit` function, fill `varInit` section with future values of our `Ballot` contract static variables and use the keyword `new` for deploying.

```solidity title="Vote.sol" showLineNumbers
pragma ever-solidity >= 0.61.2;
pragma ever-solidity >= 0.62.0;
...
contract Vote {
Expand Down Expand Up @@ -85,7 +85,7 @@ Well, the votes will be stored in our Vote contract. That's why we need a specia
It can't be any easier. The address of any contract can be definitely calculated if you know state init variables, a public key and contract code:

```solidity title="Vote.sol" showLineNumbers
pragma ever-solidity >= 0.61.2;
pragma ever-solidity >= 0.62.0;
...
contract Vote {
Expand Down Expand Up @@ -135,7 +135,7 @@ function getDetails() external view returns (uint32 accepted, uint32 rejected) {
Bring it all together

```solidity title="Vote.sol" showLineNumbers
pragma ever-solidity >= 0.61.2;
pragma ever-solidity >= 0.62.0;
pragma AbiHeader expire;
pragma AbiHeader pubkey;
Expand Down Expand Up @@ -217,7 +217,7 @@ contract Vote {
Now let's deal with `Ballot` contract. There is no something special in state and constructor:

```solidity title="Ballot.sol" showLineNumbers
pragma ever-solidity >= 0.61.2;
pragma ever-solidity >= 0.62.0;
pragma AbiHeader expire;
pragma AbiHeader pubkey;
Expand Down Expand Up @@ -249,7 +249,7 @@ contract Ballot {
Let's talk about the activation mechanic. In constructor, we already reserved little more venoms. We made it with the purpose, that fee for the external call will be paid from the contract balance. That way of gas management allows us to transfer external calls fee-paying to user responsibility. But activate method shouldn't be called by somebody unauthorized, so we just use `require` keyword by comparing `msg.pubkey` and `_managerPublicKey` stored in state init. Of course, you need to call `tvm.accept()` function. Simply put, this call allows the contract to use its own balance for executive pay.

```solidity title="Ballot.sol" showLineNumbers
pragma ever-solidity >= 0.61.2;
pragma ever-solidity >= 0.62.0;
...
import "./interfaces/IVote.sol";
Expand All @@ -276,7 +276,7 @@ Let's implement the main function of our `Ballot` - `vote`.
Pay attention to imports. We have `import "./interfaces/IVote.sol"`. It's just an interface for calling our `Vote` contract (just like for EVM if you know what I mean). 

```solidity title="interfaces/IVote.sol" showLineNumbers
pragma ever-solidity >= 0.61.2;
pragma ever-solidity >= 0.62.0;
pragma AbiHeader expire;
interface IVote {
Expand All @@ -287,7 +287,7 @@ interface IVote {
Let us now return to `vote` function

```solidity title="Ballot.sol" showLineNumbers
pragma ever-solidity >= 0.61.2;
pragma ever-solidity >= 0.62.0;
...
import "./interfaces/IVote.sol";
Expand All @@ -313,7 +313,7 @@ contract Ballot {
That's all. `Vote` contract will check our Ballot address by calculating it, as you remember, and the vote will be accepted. But what if Vote calls will fail because of some reason (low gas attached or yet network problem!)? Our `Ballot` will be marked as used (`_used` state variable will be set as true, and we can't call vote once again). To solve this problems, TVM has [bounce](../../../../start/learn/messages-and-transactions.md) messages and [`onBounce`](https://github.com/tonlabs/TON-Solidity-Compiler/blob/master/API.md#onbounce) function for handling them. Let's deal with it by example

```solidity title="Ballot.sol" showLineNumbers
pragma ever-solidity >= 0.61.2;
pragma ever-solidity >= 0.62.0;
...
import "./interfaces/IVote.sol";
Expand All @@ -337,7 +337,7 @@ contract Ballot {
That's it. Now let's bring it all together. 

```solidity title="Ballot.sol" showLineNumbers
pragma ever-solidity >= 0.61.2;
pragma ever-solidity >= 0.62.0;
pragma AbiHeader expire;
pragma AbiHeader pubkey;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ ls ./build
> ...
```

### Deploy your token

Let's move to deploy. Firstly, we make a new deploy script in `scripts` directory for the `TokenRoot` contract. 

```typescript title="01-deploy-token-root.ts" showLineNumbers
Expand Down Expand Up @@ -165,13 +167,20 @@ docker run -d --name local-node -e USER_AGREEMENT=yes -p80:80 tonlabs/local-node
and run the deploy script

```shell
npx locklift run -s ./scripts/01-deploy-token.ts -n local

npx locklift run -s ./scripts/01-deploy-token-root.ts -n local
> Found 1 sources

> factorySource generated
> Built
> First Venom Token: 0:69f2407386ca20390878565da97124be717f65496cb03e14aaa676709a6ccb2b
```

:::danger Deployment Error
When trying to deploy the script, you may encounter the following error:
`Cannot use "in" operator to search for 'map' in undefined`

This issue is still current. A solution can be found at this GitHub link:
[Error Fix](https://github.com/venom-blockchain/locklift/pull/15/commits/9a4d3c87d4ed673288cbf7c9d52cff45d1a78e6b).
:::

Congratulations, your first token on the Venom network has been deployed!
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,14 @@ Now you can just use the same deploy scripts, but with another network. For exam
```shell
npx locklift run -s ./scripts/01-deploy-token.ts -n venomTestnet
```
:::caution Deployment Error
When trying to deploy the script, you may encounter the following error:
`Cannot use "in" operator to search for 'map' in undefined`
This issue is still current. A solution can be found at this GitHub link:
[Error Fix](https://github.com/venom-blockchain/locklift/pull/15/commits/9a4d3c87d4ed673288cbf7c9d52cff45d1a78e6b).
:::
Summarizing:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ compiler: {
Now we can start with our tokensale contract. Create a `Tokensale.tsol` file in your `contracts` folder. First of all, let's arrange pragmas and imports.

```solidity title="Tokensale.tsol" showLineNumbers
pragma ever-solidity >= 0.61.2;
pragma ever-solidity >= 0.62.0;
pragma AbiHeader expire;
pragma AbiHeader pubkey;
Expand Down Expand Up @@ -183,7 +183,7 @@ Pay attention to `value` and `flag`. Again 0 and 128. This allows us to delegate
So, let's check our final contract code

```solidity title="Tokensale.tsol" showLineNumbers
pragma ever-solidity >= 0.61.2;
pragma ever-solidity >= 0.62.0;
pragma AbiHeader expire;
pragma AbiHeader pubkey;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ ITokenRoot(distributedTokenRoot).deployWallet {
Just create some library:

```solidity title="TokensaleGas.sol" showLineNumbers
pragma ever-solidity >= 0.61.2;
pragma ever-solidity >= 0.62.0;
library TokensaleGas {
uint128 constant INITIAL_BALANCE = 0.7 ever;
Expand All @@ -43,7 +43,7 @@ library TokensaleGas {
So that allows you to easily change gas variables for your contract

```solidity title="Tokensale.sol" showLineNumbers
pragma ever-solidity >= 0.61.2;
pragma ever-solidity >= 0.62.0;
...
import "./gas/TokensaleGas.sol"
Expand Down Expand Up @@ -71,15 +71,15 @@ contract Tokensale {
You can accept the same idea for error codes:

```solidity title="TokensaleErrors.sol" showLineNumbers
pragma ever-solidity >= 0.61.2;
pragma ever-solidity >= 0.62.0;
library TokensaleErrors {
uint8 constant BAD_ROOT_CALL = 101;
}
```

```solidity title="Tokensale.sol" showLineNumbers
pragma ever-solidity >= 0.61.2;
pragma ever-solidity >= 0.62.0;
...
import "./errors/TokensaleErrors.sol"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ npm i --save-dev @broxus/tip4
Next, you should implement two interfaces in two contracts. Firstly, let's deal with Nft contract. The only thing we should do for basics is implementing `TIP4_1Nft`` 

```solidity title="Nft.tsol" showLineNumbers
pragma ever-solidity >= 0.61.2;
pragma ever-solidity >= 0.62.0;
pragma AbiHeader expire;
pragma AbiHeader time;
Expand All @@ -78,7 +78,7 @@ contract Nft is TIP4_1Nft {
Now we should go for the Collection contract. We should implement `TIP4_1Collection` and write some method for NFT deploying.

```solidity title="Collection.tsol" showLineNumbers
pragma ever-solidity >= 0.61.2;
pragma ever-solidity >= 0.62.0;
pragma AbiHeader expire;
pragma AbiHeader time;
Expand Down Expand Up @@ -126,7 +126,7 @@ contract Collection is TIP4_1Collection {
The previous code uses only TIP-4.1 part of TIP-4. But it is kinda useless. To work with your NFT with full NFT experience you should implement [TIP-4.2](../../../standards/TIP/TIP-4/2.md) - standard, which helps you with NFT metadata storing. Also, you will need [TIP-4.3](../../../standards/TIP/TIP-4/3.md) - standard, which helps other dApps to find all your NFT with single query (GQL or JRPC). You should study the information about these standards by links. Implementation of 4.2 and 4.3 is pretty simple.

```solidity title="Nft.tsol" showLineNumbers
pragma ever-solidity >= 0.61.2;
pragma ever-solidity >= 0.62.0;
pragma AbiHeader expire;
pragma AbiHeader pubkey;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ NFT creation is a green arrow flow, and auction bids are yellow. Let's describe
That's all! As you can see, the main mechanic of our interaction is callbacks. Let's start implementing our contracts. First, implement Collection and NFT contracts same as in TIP-4 [quick start](../quick-start-developing-with-tip-4.md) guide.

```solidity title="Collection.tsol" showLineNumbers
pragma ever-solidity >= 0.61.2;
pragma ever-solidity >= 0.62.0;
pragma AbiHeader expire;
pragma AbiHeader time;
Expand Down Expand Up @@ -122,7 +122,7 @@ contract Collection is TIP4_2Collection, TIP4_3Collection {
```

```solidity title="NFT.tsol" showLineNumbers
pragma ever-solidity >= 0.61.2;
pragma ever-solidity >= 0.62.0;
pragma AbiHeader expire;
pragma AbiHeader pubkey;
Expand Down Expand Up @@ -199,7 +199,7 @@ We won't explain this code blocks because it's already done in TIP-4 [quick star
Then, let's deal with `Auction` contract. We'll get started from the state and constructor, as usual. Do not forget to add the interfaces we need.

```solidity code title="Auction.tsol" showLineNumbers
pragma ever-solidity >= 0.61.2;
pragma ever-solidity >= 0.62.0;
pragma AbiHeader expire;
pragma AbiHeader time;
Expand Down Expand Up @@ -271,7 +271,7 @@ contract Auction is INftTransfer, IAcceptTokensTransferCallback {
Remember about gas management and token wallet deploying mechanics from the previous Venom In Action [guide](../../how-to-create-your-own-fungible-tip-3-token/venom-in-action/simple-tokensale.md). Implement `onTokenWallet` callback the same way.

```solidity title="Auction.tsol" showLineNumbers
pragma ever-solidity >= 0.61.2;
pragma ever-solidity >= 0.62.0;
...
contract Auction is INftTransfer, IAcceptTokensTransferCallback {
...
Expand All @@ -293,7 +293,7 @@ contract Auction is INftTransfer, IAcceptTokensTransferCallback {
Ok, the next callback we need is `onNftTransfer`, which will be called when the NFT owner sends NFT to the auction address

```solidity title="Auction.tsol" showLineNumbers
pragma ever-solidity >= 0.61.2;
pragma ever-solidity >= 0.62.0;
...
contract Auction is INftTransfer, IAcceptTokensTransferCallback {
...
Expand Down Expand Up @@ -334,7 +334,7 @@ contract Auction is INftTransfer, IAcceptTokensTransferCallback {
Great! Now we are ready to accept bids. Let's implement another callback `onAcceptTokensTransfer`, that our `TokenWallet` will call any time it got an incoming token transaction. Take attention! This is the main logic of our auction!

```solidity title="Auction.tsol" showLineNumbers
pragma ever-solidity >= 0.61.2;
pragma ever-solidity >= 0.62.0;
...
contract Auction is INftTransfer, IAcceptTokensTransferCallback {
...
Expand Down Expand Up @@ -396,7 +396,7 @@ contract Auction is INftTransfer, IAcceptTokensTransferCallback {
That's it. How hard is that? The last thing we need - is `finishAuction` function.

```solidity title="Auction.tsol" showLineNumbers
pragma ever-solidity >= 0.61.2;
pragma ever-solidity >= 0.62.0;
...
contract Auction is INftTransfer, IAcceptTokensTransferCallback {
...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const LOCAL_NETWORK_ENDPOINT = "http://localhost/graphql";

const config: LockliftConfig = {
compiler: {
version: "0.61.2",
version: "0.62.0",
},
linker: {
version: "0.15.48",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,11 @@ Everdev is built with Ever SDK.

## Venom Network access

:::caution
The Venom network is running in testnet and cannot be used to run your own node now. Please note that any results obtained using these tutorials might be more accurate or reliable in future. You can use only our public testnet graphql API. Please wait for official announcements.
:::

To access the Venom Blockchain while trying out the guides in this section, use the official GraphQL Venom endpoint provided by [Evercloud](../using-evercloud-graphql-api-to-work-with-venom/readme.md).

Everdev tool and SDK used in the examples below can connect to it, as if it were a regular node. It has the same API as the supernode and [local node for testing](https://github.com/tonlabs/evernode-se), and provides all needed capabilities.

The Venom blockchain endpoint is available at:

https://gql-testnet.venom.foundation/graphql
**For Mainnet**: https://gql.venom.foundation/graphql
**For Testnet**: https://gql-testnet.venom.foundation/graphql
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ Other GraphQL guides and samples are available in Evercloud documentation and ar

Run these samples on the Venom testnet public endpoint: https://gql-testnet.venom.foundation/graphql



## GraphQL samples and guides

- [Send Message](https://docs.evercloud.dev/samples/graphql-samples/send-message) - send a message to blockchain via GraphQL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,9 @@ Full Evercloud and GraphQL API documentation is available at https://docs.evercl

## Venom Network access

:::caution
The Venom network is running in testnet and cannot be used to run your own node now. Please note that any results obtained using these tutorials might be more accurate or reliable in future. You can use only our public testnet graphql API. Please wait for official announcements.
:::

To access the Venom Blockchain while trying out the guides in this section, use the official GraphQL Venom endpoint available at:

https://gql-testnet.venom.foundation/graphql

**For Mainnet**: https://gql.venom.foundation/graphql
**For Testnet**: https://gql-testnet.venom.foundation/graphql


2 changes: 1 addition & 1 deletion docs/build/quick-start-on-testnet.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ To deploy your wallet or any other smart contract or for any interaction with an

## Explore the Explorer

One of the most important tools for a developer is the explorer. It allows you to see the state of the blockchain and smart contracts, transactions, token transfers etc. You can use [Venom Explorer](https://testnet.venomscan.com/) or the [alternative explorer](https://testnet.venomscan.live/blocks) to see the state of the blockchain and the smart contracts.
One of the most important tools for a developer is the explorer. It allows you to see the state of the blockchain and smart contracts, transactions, token transfers etc. You can use [Venom Explorer](https://testnet.venomscan.com/) to see the state of the blockchain and the smart contracts.

## Check some tutorials

Expand Down
4 changes: 2 additions & 2 deletions docs/standards/TIP/TIP-4/5.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ The keywords “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL N
#### `ICantBeEvil.sol`

```solidity
pragma ever-solidity >= 0.61.2;
pragma ever-solidity >= 0.62.0;
interface ICantBeEvil {
function getLicenseURI() external view responsible returns (string);
Expand All @@ -58,7 +58,7 @@ interface ICantBeEvil {
#### `CantBeEvil.sol`

```solidity
pragma ever-solidity >= 0.61.2;
pragma ever-solidity >= 0.62.0;
import "./ICantBeEvil.sol";
Expand Down
2 changes: 1 addition & 1 deletion docs/standards/TIP/TIP-4/core-description.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ General information about NFT metadata. [TIP-4.2](./../TIP-4/2.md) is optional,

## (Status:Review) [On-chain indexes (TIP-4.3)](./../TIP-4/3.md)

On-chain Indexes solves easy and fast searching any data in blockchain. [TIP-4.3](./../TIP-4/3.md) is optional, but can be use for find all your NFT with one [dApp](https://gql-testnet.venom.foundation/graphql) query.
On-chain Indexes solves easy and fast searching any data in blockchain. [TIP-4.3](./../TIP-4/3.md) is optional, but can be use for find all your NFT with one [dApp](https://gql.venom.foundation/graphql) query.

## (Status:Draft) [On-chain storage (TIP-4.4)](./../TIP-4/4.md)

Expand Down
Loading

0 comments on commit 7c4124b

Please sign in to comment.