✏️
go-conflux-sdk
  • README
  • Quickstart
  • Getting Started
    • Run a Node locally
    • Interacting with a Node
    • Deploy and Interact with Smart Contracts
    • Subscription
  • Smart Contracts
    • Smart Contract Overview
    • Getting Started with Solidity
    • Compiling Solidity source code
    • Interacting with Smart Contracts
    • Application Binary Interface
    • Contracts Supported
  • Transactions
    • Conflux Transactions
    • Obtaining CFX
    • Gas & Storage Collateral
    • Account Manager
    • Transfer CFX
    • Transaction Nonce
    • Batch Call snd Send Transactions
  • Other
    • Call/BatchCall RPC Hook
    • Conflux Addreess
  • Conflux-ABIGEN
  • ChangeLog
  • References
Powered by GitBook
On this page
  • Start sending requests
  • Send Transaction

Was this helpful?

  1. Getting Started

Interacting with a Node

Start sending requests

To send requests:

client, err := sdk.NewClient("https://test.confluxrpc.com", sdk.ClientOption{
    KeystorePath: "../keystore",
})

epoch, err := client.GetEpochNumber()

Send Transaction

Create UnsigendTransaction and send transaction by Client.SendTransaction, the Client will automatically populate the transaction and sign it before sending.

client, err := sdk.NewClient("https://test.confluxrpc.com", sdk.ClientOption{
    KeystorePath: "../keystore",
})

var utx types.UnsignedTransaction
utx.From = ... //use default account if not set
utx.To = ...
utx.value = ...
utx.Data = ...
// unlock account 
err = client.AccountManager.UnlockDefault(*utx.From, "hello")
if err != nil {
	log.Fatal(err)
}
txhash, err := client.SendTransaction(utx)
PreviousRun a Node locallyNextDeploy and Interact with Smart Contracts

Last updated 3 years ago

Was this helpful?