Endless
  • 🚀README
  • Discovery
    • 🚀Endless Web3 Genesis Cloud
    • 💎Business Model
    • 🎯Vision
    • ✈️Roadmap
    • 🪙Economics
    • 👤Team
      • Yu Xiong
      • Amit Kumar Jaiswal
      • Ned
      • 0xfun
      • Scott Trowbridge
      • Neeraj Sharma LLB
      • Amjad Suleman
      • Binu Paul
      • Eduard Romulus GOEAN
    • ❤️Developer Community
  • Endless Chain
    • Tech Docs
      • Account Address Format
      • Endless Account
      • Endless Coin(EDS)
      • Sponsored Transaction
      • On-Chain Multisig
      • Randomness
      • Safety Transaction
      • Token Locking & Distribution
    • Start
      • Learn about Endless
        • Accounts
        • Resources
        • Events
        • Transactions and States
        • Gas and Storage Fees
        • Computing Transaction Gas
        • Blocks
        • Staking
          • Delegated Staking
        • Governance
        • Endless Blockchain Deep Dive
          • Validator Nodes Overview
          • Fullnodes Overview
          • Node Networks and Synchronization
        • Move - A Web3 Language and Runtime
      • Explore Endless
      • Latest Endless Releases
      • Networks
    • Build
      • Tutorials
        • Your First Transaction
        • Your First Fungible Asset
        • Your First NFT
        • Your First Move Module
        • Your First Multisig
      • Learn the Move Language
        • The Move Book
          • Getting Started
            • Introduction
            • Modules and Scripts
          • Primitive Types
            • Move Tutorial
            • Integers
            • Bool
            • Address
            • Vector
            • Signer
            • References
            • Tuples and Unit
          • Basic Concepts
            • Local Variables and Scope
            • Equality
            • Abort and Assert
            • Conditionals
            • While, For, and Loop
            • Functions
            • Structs and Resources
            • Constants
            • Generics
            • Abilities
            • Uses and Aliases
            • Friends
            • Packages
            • Package Upgrades
            • Unit Tests
          • Global Storage
            • Global Storage - Structure
            • Global Storage - Operators
          • Reference
            • Libraries
            • Move Coding Conventions
        • Advanced Move Guides
          • Objects
            • Creating Objects
            • Configuring objects
            • Using objects
          • Move Scripts
            • Writing Move Scripts
            • Compiling Move Scripts
            • Running Move Scripts
            • Move Scripts Tutorial
          • Resource Accounts
          • Modules on Endless
          • Cryptography
          • Gas Profiling
          • Security
      • Endless Standards
        • Object
        • Endless Fungible Asset Standard
        • Endless Digital Asset Standard
        • Endless Wallet Standard
      • Endless APIs
        • Fullnode Rest API
        • Indexer Restful API
          • Indexer Installation
        • GRPC Transaction Stream
          • Running Locally
          • Custom Processors
            • End-to-End Tutorial
            • Parsing Transactions
          • Self-Hosted Transaction Stream Service
      • Endless SDKs
        • TypeScript SDK
          • Account
          • SDK Configuration
          • Fetch data from chain
          • Transaction Builder
          • HTTP Client
          • Move Types
          • Testing
          • Typescript
        • Rust SDK
        • Go SDK
      • Endless CLI
        • Install the Endless CLI
          • Install On Mac
          • Install On Alibaba Cloud
          • Install On Linux
          • Install On Windows
        • CLI Configuration
        • Use Endless CLI
          • Working With Move Contracts
            • Arguments in JSON Tutorial
          • Trying Things On-Chain
            • Look Up On-Chain Account Info
            • Create Test Accounts
          • Running A Local Network
            • Running a Public Network
          • Managing a Network Node
      • Integrate with Endless
        • Endless Token Overview
        • Application Integration Guide
      • Endless VSCode extension
      • Advanced Builder Guides
        • Develop Locally
          • Running a Local Network
          • Run a Localnet with Validator
    • Nodes
      • Learn about Nodes
      • Run a Validator and VFN
        • Node Requirements
        • Deploy Nodes
          • Using Docker
          • Using AWS
          • Using Azure
          • Using GCP
        • Connect Nodes
          • Connect to a Network
        • Verify Nodes
          • Node Health
          • Validator Leaderboard
      • Run a Public Fullnode
        • PFN Requirements
        • Deploy a PFN
          • Using Pre-compiled Binary
          • Using Docker
          • Using GCP 🚧 (under_construction)
        • Verify a PFN
        • Modify a PFN
          • Upgrade your PFN
          • Generate a PFN Identity
          • Customize PFN Networks
      • Bootstrap a Node
        • Bootstrap from a Snapshot
        • Bootstrap from a Backup
      • Configure a Node
        • State Synchronization
        • Data Pruning
        • Telemetry
        • Locating Node Files
          • Files For Mainnet
          • Files For Testnet
          • Files For Devnet
      • Monitor a Node
        • Node Inspection Service
        • Important Node Metrics
        • Node Health Checker
    • Reference
      • Endless Error Codes
      • Move Reference Documentation
      • Endless Glossary
    • FAQs
  • Endless Bridge
    • Intro to Endless Bridge
    • How to use bridge
    • Liquidity Management
    • Faucet
    • Developer Integration
      • Contract Integration
        • Message Contract
        • Execute Contract
      • Server-Side Integration
        • Message Sender
        • Example of Message Listener Service (Rust)
        • Example of Token Cross-Chain (JS)
  • Endless Wallet
    • User Guide
    • Basic Tutorial
    • FAQs
    • MultiAccount
    • SDK
      • Functions
      • Events
  • GameFi
    • Intro
    • GameFi & Endless
  • Endless Modules
    • Stacks
    • Storage
    • Module List
  • Endless Ecosystem
    • Intro
    • Show Cases
    • App Demo
  • Whitepaper
  • Endless SCAN
    • User Guide
  • MULTI-SIGNATURE
    • Multi-Signature User Guide
  • Regulations
    • Privacy Policy
    • Terms of Service
    • Funding Terms - Disclaimer
Powered by GitBook
On this page
  • Step 1: Pick an SDK
  • Step 2: Run the example
  • Step 3: Understand the output
  • Step 4: The SDK in depth
  • Step 4.1: Initializing the clients
  • Step 4.2: Creating local accounts
  • Step 4.3: Creating blockchain accounts
  • Step 4.4: Reading balances
  • Step 4.5: Transferring
  • Step 4.6: Waiting for transaction resolution
  • Supporting documentation
Export as PDF
  1. Endless Chain
  2. Build
  3. Tutorials

Your First Transaction

PreviousTutorialsNextYour First Fungible Asset

Last updated 2 months ago

This tutorial describes how to generate and submit transactions to the Endless blockchain, and verify these submitted transactions. The transfer-coin example used in this tutorial is built with the Endless SDKs.

Step 1: Pick an SDK

Install your preferred SDK from the below list:

  • TypeScript SDK

  • Rust SDK


Step 2: Run the example

Clone the endless-ts-sdk repo and build it:

git clone https://github.com/endless-labs/endless-ts-sdk.git
cd endless-ts-sdk
pnpm install
pnpm build

Navigate to the Typescript examples directory:

cd examples/endless

Install the necessary dependencies:

pnpm install

Run the example:

pnpm run transfer_coin

Clone the endless-core repo:

git clone https://github.com/endless-labs/endless.git

Rust

Clone the endless-core repo:

git clone https://github.com/endless-labs/endless.git

Navigate to the Rust SDK directory:

cd endless-core/sdk
cargo run --example transfer_coin

Step 3: Understand the output

An output very similar to the following will appear after executing the above command:

=== Addresses ===

Alice's address is: 0xbd20517751571ba3fd06326c23761bc0bc69cf450898ffb43412fbe670c28806
Bob's address is: 0x8705f98a74f5efe17740276ed75031927402c3a965e10f2ee16cda46d99d8f7f

=== Funding Alice ===

=== Initial Balances ===

Alice's balance is: 1000000000
Bob's balance is: 0

=== Transfer 1000000 from Alice to Bob ===

Committed transaction: 0xc0d348afdfc34ae2c48971b253ece727cc9980dde182e2f2c42834552cbbf04c

=== Balances after transfer ===

Alice's balance is: 998899500
Bob's balance is: 1000000

The above output demonstrates that the transfer-coin example executes the following steps:

  • Initializing the Endless client.

  • The creation of two accounts: Alice and Bob.

  • The funding and creation of Alice's account from a faucet.

  • The transferring of 1000000 coins from Alice to Bob.

  • The 100500 coins of gas paid for by Alice to make that transfer.

Now see the below walkthrough of the SDK functions used to accomplish the above steps.


Step 4: The SDK in depth


Step 4.1: Initializing the clients

In the first step, the transfer_coin example initializes the Endless client:

const config = new EndlessConfig({
  network: Network.TESTNET,
  fullnode: "https://rpc-test.endless.link/v1",
  indexer: "https://idx-test.endless.link/api/v1",
});
const endless = new Endless(config);

By default, the Endless client points to Endless testnet services. However, it can be configured with the network input argument

In the first step, the `transfer_coin` example initializes the REST and indexer clients:

  • The REST client interacts with the REST API.

  • The indexer client interacts with the tesnet indexer service for complex searching.


Step 4.2: Creating local accounts

The next step is to create two accounts locally. Accounts represent both on and off-chain state. Off-chain state consists of an address and the public/private key pair used to authenticate ownership. This step demonstrates how to generate that off-chain state.

const alice = Account.generate();
const bob = Account.generate();

Step 4.3: Creating blockchain accounts

In Endless, each account must have an on-chain representation in order to receive tokens and coins and interact with other dapps. An account represents a medium for storing assets; hence, it must be explicitly created. This example leverages the Faucet to create and fund Alice's account and to create but not fund Bob's account:

const fund_tx = await endless.fundAccount({ signer: alice });
await endless.waitForTransaction({ transactionHash: fund_tx.hash });

Step 4.4: Reading balances

In this step, the SDK translates a single call into the process of querying a resource and reading a field from that resource.

const ALICE_INITIAL_BALANCE = await endless.viewEDSBalance(alice.accountAddress);
const BOB_INITIAL_BALANCE = await endless.viewEDSBalance(bob.accountAddress);

Behind the scenes, the balance function uses the SDK viewCoinBalance function that reads the FungibleStore stored value:

const EDSMetadataAddress = "ENDLESSsssssssssssssssssssssssssssssssssssss";

return viewCoinBalance({
  endlessConfig: this.config,
  account,
  fungibleAssetMetadataAddress: AccountAddress.from(EDSMetadataAddress),
});

Step 4.5: Transferring

Like the previous step, this is another helper step that constructs a transaction transferring the coins from Alice to Bob. The SDK provides a helper function to generate a transferEDS transaction that can be simulated or submitted to chain. Once a transaction has been submitted to chain, the API will return a transaction hash that can be used in the subsequent step to check on the transaction status. The Endless blockchain does perform a handful of validation checks on submission; and if any of those fail, the user will instead be given an error. These validations use the transaction signature and unused sequence number, and submitting the transaction to the appropriate chain.

const transaction = await endless.transferEDS({
  sender: alice,
  recipient: bob.accountAddress,
  amount: Number(TRANSFER_AMOUNT),
});
const pendingTxn = await endless.signAndSubmitTransaction({ signer: alice, transaction });

Behind the scenes, the transferEDS function generates a transaction payload that can be simulated or submitted to chain:

export async function transferEDS(args: {
  endlessConfig: EndlessConfig;
  sender: Account;
  recipient: AccountAddress;
  amount: AnyNumber;
  options?: InputGenerateTransactionOptions;
}): Promise<SimpleTransaction> {
  const { endlessConfig, sender, recipient, amount, options } = args;
  return generateTransaction({
    endlessConfig,
    sender: sender.accountAddress,
    data: {
      function: "0x1::endless_account::transfer",
      functionArguments: [recipient, amount],
      abi: transferEDSAbi,
    },
    options,
  });
}

Breaking the above down into pieces:

  1. The Move function is stored on the endless_account module: 0x1::endless_account.

Like the previous step, this is another helper step that constructs a transaction transferring the coins from Alice to Bob. For correctly generated transactions, the API will return a transaction hash that can be used in the subsequent step to check on the transaction status. The Endless blockchain does perform a handful of validation checks on submission; and if any of those fail, the user will instead be given an error. These validations use the transaction signature and unused sequence number, and submitting the transaction to the appropriate chain.


Step 4.6: Waiting for transaction resolution

In the TypeScript SDK, just calling waitForTransaction is sufficient to wait for the transaction to complete. The function will return the Transaction returned by the API once it is processed (either successfully or unsuccessfully) or throw an error if processing time exceeds the timeout.

const response = await endless.waitForTransaction({
  transactionHash: pendingTxn.hash,
});

The transaction hash can be used to query the status of a transaction:

Supporting documentation

Run the example:

The transfer-coin example code uses helper functions to interact with the . This section reviews each of the calls and gives insights into functionality.

See the full code See the TypeScript for the complete code as you follow the below steps.

transfer_coins internally is a EntryFunction in the , i.e. an entry function in Move that is directly callable.

transfer_coin
transfer_coin
REST API
transfer_coin
Endless Account Move module
Account basics
TypeScript SDK
Golang SDK
Rust SDK
REST API specification