Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/codemaveric/libra-go
Go Client for interacting with Libra Blockchain
https://github.com/codemaveric/libra-go
blockchain blockchain-technology cryptocurrency go golang golang-package libra libra-go
Last synced: 3 months ago
JSON representation
Go Client for interacting with Libra Blockchain
- Host: GitHub
- URL: https://github.com/codemaveric/libra-go
- Owner: codemaveric
- License: mit
- Created: 2019-06-26T16:43:07.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-11-26T12:20:47.000Z (almost 5 years ago)
- Last Synced: 2024-06-26T03:33:08.994Z (5 months ago)
- Topics: blockchain, blockchain-technology, cryptocurrency, go, golang, golang-package, libra, libra-go
- Language: Go
- Size: 139 KB
- Stars: 49
- Watchers: 6
- Forks: 13
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-libra - Libra Golang Client - Go Client for interacting with Libra Blockchain. (Go)
- awesome-diem - Libra Go Client - a go client for interacting with Libra blockchain (Testnet / Libraries)
README
# Libra Golang Client
Libra Golang Client is library to interact with Libra Blockchain> Note: The project is still under major development! The Package is not stable and will keep changing!
## Installation
To install run:`go get github.com/codemaveric/libra-go/pkg/goclient`
## Usage
Example```Go
package mainimport (
"log"
"strings""github.com/codemaveric/libra-go/pkg/goclient"
"github.com/codemaveric/libra-go/pkg/librawallet"
)func main() {
// I will advice you to change the mnemonic to something else
mnemonic := "present good satochi coin future media giant"
wallet := librawallet.NewWalletLibrary(mnemonic)
address, childNum, err := wallet.NewAddress()
if err != nil {
log.Fatal(err)
}
log.Print(address.ToString())// Generate Keypair with mnemonic and childNum
keyPair := librawallet.GenerateKeyPair(strings.Split(mnemonic, " "), childNum)// Create Account from KeyPair
sourceAccount := librawallet.NewAccountFromKeyPair(keyPair)
// Libra Client Configuration
config := goclient.LibraClientConfig{
Host: "ac.testnet.libra.org",
Port: "80",
Network: goclient.TestNet,
}
// Instantiate LibraClient with Configuration.
libraClient := goclient.NewLibraClient(config)// Mint Coin from Test Faucet to account generated.
err = libraClient.MintWithFaucetService(sourceAccount.Address.ToString(), 500000000, true)if err != nil {
log.Fatal(err)
}// Get Account State.
SourceaccState, err := libraClient.GetAccountState(sourceAccount.Address.ToString())
if err != nil {
log.Fatal(err)
}
log.Print(SourceaccState.Balance)// Set the current account sequence.
sourceAccount.Sequence = SourceaccState.SequenceNumber// Transfer Coins from source account to destination address.
err = libraClient.TransferCoins(sourceAccount, "f4aebe371e4176143c3409122d0adf43c0e00a6552b5b0ae9980d8981fcd0221", 11000000, 0, 10000, true)
if err != nil {
log.Fatal(err)
}
// Get Account Transaction by Sequence Number.
transaction, err := libraClient.GetAccountTransaction(sourceAccount.Address.ToString(), 0, true)if err != nil {
log.Fatal(err)
}log.Println(transaction)
}```
## Contribution
Feel free to contribute by opening issues or PR's.## License
MIT