Giter Site home page Giter Site logo

suitity's Introduction

Disclaimer: Use of Unaudited Code for Educational Purposes Only

This code is provided strictly for educational purposes and has not undergone any formal security audit. It may contain errors, vulnerabilities, or other issues that could pose risks to the integrity of your system or data.

By using this code, you acknowledge and agree that:

  • No Warranty: The code is provided "as is" without any warranty of any kind, either express or implied. The entire risk as to the quality and performance of the code is with you.
  • Educational Use Only: This code is intended solely for educational and learning purposes. It is not intended for use in any mission-critical or production systems.
  • No Liability: In no event shall the authors or copyright holders be liable for any claim, damages, or other liability, whether in an action of contract, tort, or otherwise, arising from, out of, or in connection with the use or performance of this code.
  • Security Risks: The code may not have been tested for security vulnerabilities. It is your responsibility to conduct a thorough security review before using this code in any sensitive or production environment.
  • No Support: The authors of this code may not provide any support, assistance, or updates. You are using the code at your own risk and discretion.

Before using this code, it is recommended to consult with a qualified professional and perform a comprehensive security assessment. By proceeding to use this code, you agree to assume all associated risks and responsibilities.

Setup

Prerequisites

Before we proceed, we should install a couple of things. Also, if you are using a Windows machine, it's recommended to use WSL2.

On Ubuntu/Debian/WSL2(Ubuntu):

sudo apt update
sudo apt install curl git-all cmake gcc libssl-dev pkg-config libclang-dev libpq-dev build-essential -y

On MacOs:

brew install curl cmake git libpq

If you don't have brew installed, run this:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Next, we need rust and cargo:

curl https://sh.rustup.rs -sSf | sh

Install Sui

If you are using Github codespaces, it's recommended to use pre-built binaries rather than building them from source.

To download pre-built binaries, you should run download-sui-binaries.sh in the terminal. This scripts takes three parameters (in this particular order) - version, environment and os:

  • sui version, for example 1.15.0. You can lookup a more up-to-date version available here SUI Github releases.
  • environment - that's the environment that you are targeting, in our case it's devnet. Other available options are: testnet and mainnet.
  • os - name of the os. If you are using Github codespaces, put ubuntu-x86_64. Other available options are: macos-arm64, macos-x86_64, ubuntu-x86_64, windows-x86_64 (not for WSL).

To donwload SUI binaries for codespace, run this command:

./download-sui-binaries.sh "v1.15.0" "devnet" "ubuntu-x86_64"

and restart your terminal window.

If you prefer to build the binaries from source, run this command in your terminal:

cargo install --locked --git https://github.com/MystenLabs/sui.git --branch devnet sui

Install dev tools (not required, might take a while when installin in codespaces)

cargo install --git https://github.com/move-language/move move-analyzer --branch sui-move --features "address32"

Run a local network

To run a local network with a pre-built binary (recommended way), run this command:

RUST_LOG="off,sui_node=info" sui-test-validator

Optionally, you can run it from sources.

git clone --branch devnet https://github.com/MystenLabs/sui.git

cd sui

RUST_LOG="off,sui_node=info" cargo run --bin sui-test-validator

Install SUI Wallet (optionally)

https://chrome.google.com/webstore/detail/sui-wallet/opcgpfmipidbgpenhmajoajpbobppdil?hl=en-GB

Configure connectivity to a local node

Once the local node is running (using sui-test-validator), you should the url of a local node - http://127.0.0.1:9000 (or similar). Also, another url in the output is the url of a local faucet - http://127.0.0.1:9123.

Next, we need to configure a local node. To initiate the configuration process, run this command in the terminal:

sui client active-address

The prompt should tell you that there is no configuration found:

Config file ["/home/codespace/.sui/sui_config/client.yaml"] doesn't exist, do you want to connect to a Sui Full node server [y/N]?

Type y and in the following prompts provide a full node url http://127.0.0.1:9000 and a name for the config, for example, localnet.

On the last prompt you will be asked which key scheme to use, just pick the first one (0 for ed25519).

After this, you should see the ouput with the wallet address and a mnemonic phrase to recover this wallet. You can save so later you can import this wallet into SUI Wallet.

Additionally, you can create more addresses and to do so, follow the next section - Create addresses.

Create addresses

For this tutorial we need two separate addresses. To create an address run this command in the terminal:

sui client new-address ed25519

where:

  • ed25519 is the key scheme (other available options are: ed25519, secp256k1, secp256r1)

And the output should be similar to this:

╭─────────────────────────────────────────────────────────────────────────────────────────────────╮
│ Created new keypair and saved it to keystore.                                                   │
├────────────────┬────────────────────────────────────────────────────────────────────────────────┤
│ address        │ 0x05db1e318f1e4bc19eb3f2fa407b3ebe1e7c3cd8147665aacf2595201f731519             │
│ keyScheme      │ ed25519                                                                        │
│ recoveryPhrase │ lava perfect chef million beef mean drama guide achieve garden umbrella second │
╰────────────────┴────────────────────────────────────────────────────────────────────────────────╯

Use recoveryPhrase words to import the address to the wallet app.

Get localnet SUI tokens

curl --location --request POST 'http://127.0.0.1:9123/gas' --header 'Content-Type: application/json' \
--data-raw '{
    "FixedAmountRequest": {
        "recipient": "<ADDRESS>"
    }
}'

<ADDRESS> - replace this by the output of this command that returns the active address:

sui client active-address

You can switch to another address by running this command:

sui client switch --address <ADDRESS>

abd run the HTTP request to mint some SUI tokens to this account as well.

Also, you can top up the balance via the wallet app. To do that, you need to import an account to the wallet.

Build and publish a smart contract

Build package

To build tha package, you should run this command:

sui move build

If the package is built successfully, the next step is to publish the package:

Publish package

sui client publish --gas-budget 100000000 --json

suitity's People

Contributors

oladayo-ahmod avatar tarasherasymchuk avatar coolestnick avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.