项目作者: bpancost

项目描述 :
An SDK for Sila written in Golang.
高级语言: Go
项目地址: git://github.com/bpancost/sila.git
创建时间: 2020-09-23T21:08:16Z
项目社区:https://github.com/bpancost/sila

开源协议:MIT License

下载


Sila Client

This project creates a native SDK for the Sila API in Golang. To learn more about Sila and how it works, please go to
their website as well as read the documentation.

Implemented Endpoints

The current version of this library implements the following endpoints according to the Sila API v0.2.

Entities

Accounts

Wallets

Transactions

Parameters

Usage

To use the Sila SDK, first import:

  1. import "github.com/bpancost/sila"

From there, create a new client by using

  1. // The the auth private key as a hex string, without the "0x" prefixed
  2. privateKeyHex := "badba7368134dcd61c60f9b56979c09196d03f5891a20c1557b1afac0202a97c"
  3. // The handle associated with your auth account
  4. authHandle := "handle.silamoney.eth"
  5. // A production client can be created by using sila.Production instead of sila.Sandbox
  6. client, err := sila.NewClient(privateKeyHex, authHandle, sila.Sandbox)

With the client, it is possible to make any of the included calls. Each is a chainable series of method calls, ending
with a call to the Do method. For example, to get a list of entities you could use

  1. response, err := silaClient.GetEntities().
  2. SetPage(1).
  3. SetPerPage(20).
  4. Do()

There are several functions within the github.com/bpancost/sila package which can be used to manipulate or create keys
for wallets, which will be required for certain calls.

  • GenerateNewPrivateKey() (string, error)
    • Generates a private key for a new wallet. This should generally not be shared or shown outside of your system and
      will be used for subsequent calls related to the wallet, or as a means of identifying the user who owns the wallet.
  • GetWalletAddress(privateKeyHex string) (string, error)
    • Gets the public address for the wallet. This is used to publicly indicate a wallet and is always visible on the
      blockchain, including any transactions.
  • GenerateWalletSignature(message []byte, walletPrivateKeyHex string) (string, error)
    • Signs an arbitrary message using a wallet’s private key as a hex string.

Integration Tests

To use the included integration tests, create a file named test_config.yaml using the test_config_sample.yaml as a
template. Provide your auth key as a hex string, your auth handle, a unique user handle specifically for this testing,
and a private key as a hex string for the integration user’s wallet which will be their main wallet. You can use a tool
like Vanity-Eth to help generate a new wallet address and private key.

Most tests will complete quickly, though the transaction tests require several minute sleeps to verify they completed
and will take around 10 minutes to complete.

If you would like to view the integration test progress via a web page, you can use goconvey from a terminal and then
navigate to http://127.0.0.1:8080.