The golang library for V Systems Blockchain.
The full functionality of SDK is still under development. The API may not be stable, please use it at your own risk.
Use go get
to retrieve the SDK sto add it to your GOPATH
workspace, or
project's Go module dependencies.
go get github.com/walkbean/vsys-sdk-go
The metadata of the SDK's dependencies can be found in the Go module file go.mod
acc := vsys.InitAccount(TestnetByte)
acc.BuildFromSeed("<SEED>", 0)
acc := vsys.InitAccount(TestnetByte)
acc.BuildFromPrivateKey("<PRIVATE_KEY>")
- Init Api
// For Mainnet
vsys.InitApi("https://wallet.v.systems/api", vsys.Mainnet)
// For TestNet
vsys.InitApi("http://test.v.systems:9922", vsys.Testnet)
- Make Transaction
// Create Payment Transaction (send 1 vsys)
tx := acc.BuildPayment("<RECIPIENT_ADDRESS>", 1e8, "<YOUR_ATTACHMENT>")
vsys.SendPaymentTx(tx)
// Create Lease Transaction (lease 1 vsys)
tx = acc.BuildLeasing("<RECIPIENT_ADDRESS>", 1e8)
vsys.SendLeasingTx(tx)
// Create Cancel Lease Transaction
tx = acc.BuildCancelLeasing("<TRANSACTION_ID>")
vsys.SendCancelLeasingTx(tx)
- Query Transaction
// Get Account Related Transactions (get payment transactions limit 10 offset 0)
list, err := vsys.GetTransactionList("<ADDRESS>", 10, 0, vsys.TxTypePayment)
Contract type now only support : vsys.TokenContract
or vsys.TokenContractWithSplit
tx := acc.BuildRegisterContract(
<CONTRACT_TYPE>,
<MAX>,
<UNITY>,
<TOKEN_DESCRIPTION>,
<CONTRACT_DESCRIPTION>)
vsys.SendRegisterContractTx(tx)
a := &vsys.Contract{
Amount: 3 * 1e8,
}
// Build issue func data, Amount is necessary
funcData := a.BuildIssueData()
tx := acc.BuildExecuteContract(
<CONTRACT_ID>,
<FUNC_INDEX>,
<FUNCDATA>,
<ATTACHMENT>)
vsys.SendExecuteContractTx(tx)
a := &vsys.Contract{
Amount: 4 * 1e8,
}
// Build destroy func data, Amount is necessary
funcData = a.BuildDestroyData()
tx := acc.BuildExecuteContract(
<CONTRACT_ID>,
<FUNC_INDEX>,
<FUNC_DATA>,
<ATTACHMENT>)
vsys.SendExecuteContractTx(tx)
a := &vsys.Contract{
Amount: 3 * 1e7,
Recipient: "AUDRgBJjXM5zFMERzMML7pLPWikajTf8AKh",
}
// Build send func data, Amount and Recipient are necessary
funcData = a.BuildSendData()
tx = acc.BuildExecuteContract(
<CONTRACT_ID>,
<FUNC_INDEX>, // eg. vsys.FuncidxSend or vsys.FuncidxSendSplit
funcData,
<ATTACHMENT>)
vsys.SendExecuteContractTx(tx)
or
tx := acc.BuildSendTokenTransaction(
<TOKEN_ID>,
<RECEPIENT>,
<AMOUNT>,
<IS_SPLIT_SUPPORTED>,
<ATTACHMENT>)
vsys.SendExecuteContractTx(tx)
a := &vsys.Contract{
NewUnity: 1e4,
}
// Build split func data, NewUnity is necessary
funcData := a.BuildSplitData()
tx := acc.BuildExecuteContract(
TokenId2ContractId(testToken),
vsys.FuncidxSplit,
funcData,
<ATTACHMENT>)
vsys.SendExecuteContractTx(tx)
Please refer to test files:
// blockchain api usage
vsys/api_test.go
// make account from seed or priKey
vsys/account_test.go
// contract relative utils usage
vsys/contract_test.go
This package is licensed under the MIT license. See LICENSE for details.