Giter Club home page Giter Club logo

sui-contract-call's Introduction

SUI.js SDK Example: Calling SUI Blockchain Smart Contract Function

Prerequisites

Ensure you have Node.js installed on your system.

Installation

npm install @mysten/sui.js/client @mysten/sui.js/transactions @mysten/sui.js/keypairs/ed25519

The provided JavaScript code utilizes the Sui.js SDK to interact with the SUI blockchain. Here's a brief overview:

Packages Used:

@mysten/sui.js/client: SUI client for interacting with the blockchain. @mysten/sui.js/transactions: TransactionBlock for building transactions. @mysten/sui.js/keypairs/ed25519: Ed25519Keypair for generating keypairs. Constants:

DISPERSE_PACKAGE_ID: Package ID of the disperse smart contract on the SUI testnet. ADMIN_MNEMONIC: Mnemonic of the transaction sender (admin). SENDER_COIN_OBJECT_ID: Object ID of the sender's coin. COIN_TYPE: Type of the coin to be transferred. SUI Client Setup:

Initialize the SUI client with the testnet full node URL. Main Function (main):

Generate an Ed25519 Keypair from the admin mnemonic. Create a new TransactionBlock. Define input arguments for the smart contract function. Build the transaction by calling the disperse_token function. Sign and execute the transaction using the SUI client. Display the transaction status and result. Helper Function (getSigner):

Derive the keypair from the admin mnemonic. Log the admin's SUI address. Return the keypair.

Install the required packages using npm install. Run the script:

node your-script-name.js View the transaction status and result.

Ensure you have the necessary dependencies installed and configured, such as Node.js and a valid SUI testnet environment.

sui-contract-call's People

Contributors

upendra-eth avatar

Watchers

 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.