Ledgerstate API Methods
Get address details for a given base58 encoded address ID, such as output types and balances. For the client library API call balances will not be directly available as values because they are stored as a raw block. Balance can be read after retrieving ledgerstate.Output
instance, as presented in the examples.
Parameter | address |
---|
Required or Optional | required |
Description | The address encoded in base58. |
Type | string |
curl http://localhost:8080/ledgerstate/addresses/:address \
-X GET \
-H 'Content-Type: application/json'
where :address
is the base58 encoded address, e.g. 6PQqFcwarCVbEMxWFeAqj7YswK842dMtf84qGyKqVH7s1kK.
resp, err := goshimAPI.GetAddressOutputs("6PQqFcwarCVbEMxWFeAqj7YswK842dMtf84qGyKqVH7s1kK")
if err != nil {
// return error
}
fmt.Println("output address: ", resp.Address)
for _, output := range resp.Outputs {
fmt.Println("outputID: ", output.OutputID)
fmt.Println("output type: ", output.Type)
// get output instance
out, err = output.ToLedgerstateOutput()
}
{
"address": {
"type": "AddressTypeED25519",
"base58": "18LhfKUkWt4M9YR6Q3au4LT8wWCERwzHaqn153K78Eixp"
},
"outputs": [
{
"outputID": {
"base58": "gdFXAjwsm5kDeGdcZsJAShJLeunZmaKEMmfHSdoX34ZeSs",
"transactionID": "32yHjeZpghKNkybd2iHjXj7NsUdR63StbJcBioPGAut3",
"outputIndex": 0
},
"type": "SigLockedColoredOutputType",
"output": {
"balances": {
"11111111111111111111111111111111": 1000000
},
"address": "18LhfKUkWt4M9YR6Q3au4LT8wWCERwzHaqn153K78Eixp"
}
}
]
}
Return field | Type | Description |
---|
address | Address | The address corresponding to provided outputID. |
outputs | Output | List of transactions' outputs. |
Field | Type | Description |
---|
type | string | The type of an address. |
base58 | string | The address encoded with base58. |
Field | Type | Description |
---|
outputID | OutputID | The identifier of an output. |
outputType | string | The type of the output. |
output | string | An output raw block containing balances and corresponding addresses. |
Field | Type | Description |
---|
base58 | string | The output identifier encoded with base58. |
transactionID | string | The transaction identifier encoded with base58. |
outputIndex | int | The index of an output. |
Gets list of all unspent outputs for the address based on a given base58 encoded address ID.
Parameter | address |
---|
Required or Optional | required |
Description | The address encoded in base58. |
Type | string |
curl http://localhost:8080/ledgerstate/addresses/:address/unspentOutputs \
-X GET \
-H 'Content-Type: application/json'
where :address
is the base58 encoded address, e.g. 6PQqFcwarCVbEMxWFeAqj7YswK842dMtf84qGyKqVH7s1kK.
address := "6PQqFcwarCVbEMxWFeAqj7YswK842dMtf84qGyKqVH7s1kK"
resp, err := goshimAPI.GetAddressUnspentOutputs(address)
if err != nil {
// return error
}
fmt.Println("output address: ", resp.Address)
for _, output := range resp.Outputs {
fmt.Println("outputID: ", output.OutputID)
fmt.Println("output type: ", output.Type)
// get output instance
out, err = output.ToLedgerstateOutput()
}
{
"address": {
"type": "AddressTypeED25519",
"base58": "18LhfKUkWt4M9YR6Q3au4LT8wWCERwzHaqn153K78Eixp"
},
"outputs": [
{
"outputID": {
"base58": "gdFXAjwsm5kDeGdcZsJAShJLeunZmaKEMmfHSdoX34ZeSs",
"transactionID": "32yHjeZpghKNkybd2iHjXj7NsUdR63StbJcBioPGAut3",
"outputIndex": 0
},
"type": "SigLockedColoredOutputType",
"output": {
"balances": {
"11111111111111111111111111111111": 1000000
},
"address": "18LhfKUkWt4M9YR6Q3au4LT8wWCERwzHaqn153K78Eixp"
}
}
]
}
Return field | Type | Description |
---|
address | Address | The address corresponding to provided unspent outputID. |
outputs | Output | List of transactions' unspent outputs. |
Field | Type | Description |
---|
type | string | The type of an address. |
base58 | string | The address encoded with base58. |
Field | Type | Description |
---|
outputID | OutputID | The identifier of an output. |
outputType | string | The type of the output. |
output | string | An output raw block containing balances and corresponding addresses |
Field | Type | Description |
---|
base58 | string | The output identifier encoded with base58. |
transactionID | string | The transaction identifier encoded with base58. |
outputIndex | int | The index of an output. |
Gets a conflict details for a given base58 encoded conflict ID.
Parameter | conflictID |
---|
Required or Optional | required |
Description | The conflict ID encoded in base58. |
Type | string |
curl http://localhost:8080/ledgerstate/conflicts/:conflictID \
-X GET \
-H 'Content-Type: application/json'
where :conflictID
is the ID of the conflict, e.g. 2e2EU6fhxRhrXVnYQ6US4zmUkE5YJip25ecafn8gZeoZ.
resp, err := goshimAPI.GetConflict("2e2EU6fhxRhrXVnYQ6US4zmUkE5YJip25ecafn8gZeoZ")
if err != nil {
// return error
}
fmt.Println("conflict ID: ", resp.ID)
fmt.Println("conflict type: ", resp.Type)
fmt.Println("conflict inclusion state: ", resp.ConfirmationState)
fmt.Println("conflict parents IDs: ", resp.Parents)
fmt.Println("conflict conflicts IDs: ", resp.ConflictIDs)
fmt.Printf("liked: %v, finalized: %v, monotonically liked: %v", resp.Liked, resp.Finalized, resp.MonotonicallyLiked)
{
"id": "5v6iyxKUSSF73yoZa6YngNN5tqoX8hJQWKGXrgcz3XTg",
"type": "ConflictConflictType",
"parents": ["4uQeVj5tqViQh7yWWGStvkEG1Zmhx6uasJtWCJziofM"],
"conflictIDs": ["3LrHecDf8kvDGZKTAYaKmvdsqXA18YBc8A9UePu7pCxw5ks"],
"liked": false,
"monotonicallyLiked": false,
"finalized": false,
"confirmationState": "ConfirmationState(Pending)"
}
Return field | Type | Description |
---|
id | string | The conflict identifier encoded with base58. |
type | string | The type of the conflict. |
parents | []string | The list of parent conflicts IDs. |
conflictIDs | []string | The list of conflicts identifiers. |
liked | bool | The boolean indicator if conflict is liked. |
monotonicallyLiked | bool | The boolean indicator if conflict is monotonically liked. |
finalized | bool | The boolean indicator if conflict is finalized. |
confirmationState | string | Confirmation state of a conflict. |
Gets a list of all child conflicts for a conflict with given base58 encoded conflict ID.
Parameter | conflictID |
---|
Required or Optional | required |
Description | The conflict ID encoded in base58. |
Type | string |
curl http://localhost:8080/ledgerstate/conflicts/:conflictID/children \
-X GET \
-H 'Content-Type: application/json'
where :conflictID
is the ID of the conflict, e.g. 2e2EU6fhxRhrXVnYQ6US4zmUkE5YJip25ecafn8gZeoZ.
resp, err := goshimAPI.GetConflictChildren("2e2EU6fhxRhrXVnYQ6US4zmUkE5YJip25ecafn8gZeoZ")
if err != nil {
//return error
}
fmt.Printf("All children conflicts for conflict %s:\n", resp.ConflictID)
for _, conflict := range resp.ChildConflicts {
fmt.Println("conflictID: ", conflict.ConflictID)
fmt.Printf("type: %s\n", conflict.ConflictID)
}
{
"conflictID": "HuYUAwCeexmBePNXx5rNeJX1zUvUdUUs5LvmRmWe7HCV",
"childConflicts": [
{
"conflictID": "4SdXm5NXEcVogiJNEKkecqd5rZzRYeGYBj8oBNsdX91W",
"type": "AggregatedConflictType"
}
]
}
Return field | Type | Description |
---|
conflictID | string | The conflict identifier encoded with base58. |
childConflicts | []ChildConflict | The child conflicts data. |
Field | Type | Description |
---|
conflictID | string | The conflict identifier encoded with base58. |
type | string | The type of the conflict. |
Get all conflicts for a given conflict ID, their outputs and conflicting conflicts.
Parameter | conflictID |
---|
Required or Optional | required |
Description | The conflicting conflict ID encoded in base58. |
Type | string |
curl http://localhost:8080/ledgerstate/conflicts/:conflictID/conflicts \
-X GET \
-H 'Content-Type: application/json'
where :conflictID
is the ID of the conflict, e.g. 2e2EU6fhxRhrXVnYQ6US4zmUkE5YJip25ecafn8gZeoZ.
resp, err := goshimAPI.GetConflictConflicts("2e2EU6fhxRhrXVnYQ6US4zmUkE5YJip25ecafn8gZeoZ")
if err != nil {
// return error
}
fmt.Printf("All conflicts for conflict %s:\n", resp.ConflictID)
// iterate over all conflicts
for _, conflict := range resp.Conflicts {
fmt.Println("output ID: ", conflict.OutputID.Base58)
fmt.Println("conflicting transaction ID: ", conflict.OutputID.TransactionID)
fmt.Printf("related conflicts: %v\n", conflict.ConflictIDs)
}
{
"conflictID": "HuYUAwCeexmBePNXx5rNeJX1zUvUdUUs5LvmRmWe7HCV",
"conflicts": [
{
"outputID": {
"base58": "41GvDSQnd12e4nWnd2WzmdLmffruXqsE46jgeUbnB8s1QnK",
"transactionID": "9wr21zza46Y5QonKEHNQ6x8puA7Rbq5LAbsQZJCK1g1g",
"outputIndex": 0
},
"conflictIDs": [
"b8QRhHerfg14cYQ4VFD7Fyh1HYTCbjt9aK1XJmdoXwq",
"HuYUAwCeexmBePNXx5rNeJX1zUvUdUUs5LvmRmWe7HCV"
]
}
]
}
Return field | Type | Description |
---|
conflictID | string | The conflict identifier encoded with base58. |
conflicts | []Conflict | The conflict data. |
Field | Type | Description |
---|
outputID | OutputID | The conflict identifier encoded with base58. |
conflictIDs | []string | The identifiers of all related conflicts encoded in base58. |
Field | Type | Description |
---|
base58 | string | The output identifier encoded with base58. |
transactionID | string | The transaction identifier encoded with base58. |
outputIndex | int | The index of an output. |
Get a list of voters of a given conflictID.
Parameter | conflictID |
---|
Required or Optional | required |
Description | The conflict ID encoded in base58. |
Type | string |
curl http://localhost:8080/ledgerstate/conflicts/:conflictID/voters \
-X GET \
-H 'Content-Type: application/json'
where :conflictID
is the ID of the conflict, e.g. 2e2EU6fhxRhrXVnYQ6US4zmUkE5YJip25ecafn8gZeoZ.
resp, err := goshimAPI.GetConflictVoters("2e2EU6fhxRhrXVnYQ6US4zmUkE5YJip25ecafn8gZeoZ")
if err != nil {
// return error
}
fmt.Printf("All voters for conflict %s:\n", resp.ConflictID)
// iterate over all voters
for _, voter := range resp.Voters {
fmt.Println("ID: ", voter)
}
{
"conflictID": "HuYUAwCeexmBePNXx5rNeJX1zUvUdUUs5LvmRmWe7HCV",
"voters": [
"b8QRhHerfg14cYQ4VFD7Fyh1HYTCbjt9aK1XJmdoXwq",
"41GvDSQnd12e4nWnd2WzmdLmffruXqsE46jgeUbnB8s1QnK"
]
}
Return field | Type | Description |
---|
conflictID | string | The conflict identifier encoded with base58. |
voters | [] string | The list of conflict voter IDs |
Get an output details for a given base58 encoded output ID, such as output types, addresses, and their corresponding balances.
For the client library API call balances will not be directly available as values because they are stored as a raw block.
Parameter | outputID |
---|
Required or Optional | required |
Description | The output ID encoded in base58. |
Type | string |
curl http://localhost:8080/ledgerstate/outputs/:outputID \
-X GET \
-H 'Content-Type: application/json'
where :outputID
is the ID of the output, e.g. 41GvDSQnd12e4nWnd2WzmdLmffruXqsE46jgeUbnB8s1QnK.
resp, err := goshimAPI.GetOutput("41GvDSQnd12e4nWnd2WzmdLmffruXqsE46jgeUbnB8s1QnK")
if err != nil {
// return error
}
fmt.Println("outputID: ", resp.OutputID.Base58)
fmt.Println("output type: ", resp.Type)
fmt.Println("transactionID: ", resp.OutputID.TransactionID)
{
"outputID": {
"base58": "41GvDSQnd12e4nWnd2WzmdLmffruXqsE46jgeUbnB8s1QnK",
"transactionID": "9wr21zza46Y5QonKEHNQ6x8puA7Rbq5LAbsQZJCK1g1g",
"outputIndex": 0
},
"type": "SigLockedColoredOutputType",
"output": {
"balances": {
"11111111111111111111111111111111": 1000000
},
"address": "1F95a2yceDicNLvqod6P3GLFZDAFdwizcTTYow4Y1G3tt"
}
}
Return field | Type | Description |
---|
outputID | OutputID | The identifier of an output. |
outputType | string | The type of the output. |
output | string | An output raw block containing balances and corresponding addresses |
Field | Type | Description |
---|
base58 | string | The output identifier encoded with base58. |
transactionID | string | The transaction identifier encoded with base58. |
outputIndex | int | The index of an output. |
Get a list of consumers based on a provided base58 encoded output ID. Transactions that contains the output and information about its validity.
Parameter | outputID |
---|
Required or Optional | required |
Description | The output ID encoded in base58. |
Type | string |
curl http://localhost:8080/ledgerstate/outputs/:outputID/consumers \
-X GET \
-H 'Content-Type: application/json'
where :outputID
is the ID of the output, e.g. 41GvDSQnd12e4nWnd2WzmdLmffruXqsE46jgeUbnB8s1QnK.
resp, err := goshimAPI.GetOutputConsumers("41GvDSQnd12e4nWnd2WzmdLmffruXqsE46jgeUbnB8s1QnK")
if err != nil {
// return error
}
fmt.Println("outputID: ", resp.OutputID.Base58)
// iterate over output consumers
for _, consumer := range resp.Consumers {
fmt.Println("transactionID: ", consumer.TransactionID)
fmt.Println("valid: ", consumer.Valid)
}
{
"outputID": {
"base58": "41GvDSQnd12e4nWnd2WzmdLmffruXqsE46jgeUbnB8s1QnK",
"transactionID": "9wr21zza46Y5QonKEHNQ6x8puA7Rbq5LAbsQZJCK1g1g",
"outputIndex": 0
},
"consumers": [
{
"transactionID": "b8QRhHerfg14cYQ4VFD7Fyh1HYTCbjt9aK1XJmdoXwq",
"valid": "true"
},
{
"transactionID": "HuYUAwCeexmBePNXx5rNeJX1zUvUdUUs5LvmRmWe7HCV",
"valid": "true"
}
]
}
Return field | Type | Description |
---|
outputID | OutputID | The output identifier encoded with base58. |
consumers | []Consumer | Consumers of the requested output. |
Field | Type | Description |
---|
base58 | string | The output identifier encoded with base58. |
transactionID | string | The transaction identifier encoded with base58. |
outputIndex | int | The index of an output. |
Field | Type | Description |
---|
transactionID | string | The transaction identifier encoded with base58. |
valid | string | The boolean indicator if the transaction is valid. |
Gets an output metadata for a given base58 encoded output ID.
Parameter | outputID |
---|
Required or Optional | required |
Description | The output ID encoded in base58. |
Type | string |
curl http://localhost:8080/ledgerstate/outputs/:outputID/metadata \
-X GET \
-H 'Content-Type: application/json'
where :outputID
is the ID of the output, e.g. 41GvDSQnd12e4nWnd2WzmdLmffruXqsE46jgeUbnB8s1QnK.
resp, err := goshimAPI.GetOutputMetadata("41GvDSQnd12e4nWnd2WzmdLmffruXqsE46jgeUbnB8s1QnK")
if err != nil {
// return error
}
fmt.Printf("Metadata of an output %s:\n", resp.OutputID.Base58)
fmt.Println("conflictID: ", resp.ConflictID)
fmt.Println("first consumer: ", resp.FirstConsumer)
fmt.Println("number of consumers: ", resp.ConsumerCount)
fmt.Printf("finalized: %v, solid: %v\n", resp.Finalized, resp.Solid)
fmt.Println("solidification time: ", time.Unix(resp.SolidificationTime, 0))
{
"outputID": {
"base58": "41GvDSQnd12e4nWnd2WzmdLmffruXqsE46jgeUbnB8s1QnK",
"transactionID": "9wr21zza46Y5QonKEHNQ6x8puA7Rbq5LAbsQZJCK1g1g",
"outputIndex": 0
},
"conflictID": "4uQeVj5tqViQh7yWWGStvkEG1Zmhx6uasJtWCJziofM",
"solid": true,
"solidificationTime": 1621889327,
"consumerCount": 2,
"firstConsumer": "HuYUAwCeexmBePNXx5rNeJX1zUvUdUUs5LvmRmWe7HCV",
"finalized": true
}
Return field | Type | Description |
---|
outputID | OutputID | The output identifier encoded with base58. |
conflictID | string | The identifier of the conflict encoded with base58. |
solid | bool | The boolean indicator if the block is solid. |
solidificationTime | int64 | The time of solidification of a block. |
consumerCount | int | The number of consumers. |
firstConsumer | string | The first consumer of the output. |
finalized | bool | The boolean indicator if the transaction is finalized. |
Field | Type | Description |
---|
base58 | string | The output identifier encoded with base58. |
transactionID | string | The transaction identifier encoded with base58. |
outputIndex | int | The index of an output. |
Gets a transaction details for a given base58 encoded transaction ID.
Parameter | transactionID |
---|
Required or Optional | required |
Description | The transaction ID encoded in base58. |
Type | string |
curl http://localhost:8080/ledgerstate/transactions/:transactionID \
-X GET \
-H 'Content-Type: application/json'
where :transactionID
is the ID of the conflict, e.g. HuYUAwCeexmBePNXx5rNeJX1zUvUdUUs5LvmRmWe7HCV.
resp, err := goshimAPI.GetTransaction("41GvDSQnd12e4nWnd2WzmdLmffruXqsE46jgeUbnB8s1QnK")
if err != nil {
// return error
}
fmt.Println("transaction inputs:")
for _, input := range resp.Inputs {
fmt.Println("inputID:", input.ReferencedOutputID.Base58)
}
fmt.Println("transaction outputs:")
for _, output := range resp.Outputs{
fmt.Println("outputID:", output.OutputID.Base58)
fmt.Println("output type:", output.Type)
}
fmt.Println("access mana pledgeID:", resp.AccessPledgeID)
fmt.Println("consensus mana pledgeID:", resp.ConsensusPledgeID)
{
"version": 0,
"timestamp": 1621889348,
"accessPledgeID": "DsHT39ZmwAGrKQe7F2rAjwHseUnJeY89gDPEH1FJxYdH",
"consensusPledgeID": "DsHT39ZmwAGrKQe7F2rAjwHseUnJeY89gDPEH1FJxYdH",
"inputs": [
{
"type": "UTXOInputType",
"referencedOutputID": {
"base58": "41GvDSQnd12e4nWnd2WzmdLmffruXqsE46jgeUbnB8s1QnK",
"transactionID": "9wr21zza46Y5QonKEHNQ6x8puA7Rbq5LAbsQZJCK1g1g",
"outputIndex": 0
}
}
],
"outputs": [
{
"outputID": {
"base58": "6gMWUCgJDozmyLeGzW3ibGFicEq2wbhsxgAw8rUVPvn9bj5",
"transactionID": "HuYUAwCeexmBePNXx5rNeJX1zUvUdUUs5LvmRmWe7HCV",
"outputIndex": 0
},
"type": "SigLockedColoredOutputType",
"output": {
"balances": {
"11111111111111111111111111111111": 1000000
},
"address": "1HrUn1jWAjrMU58LLdFhfnWBwUKVdWjP5ojp7oCL9mVWs"
}
}
],
"unlockBlocks": [
{
"type": "SignatureUnlockBlockType",
"publicKey": "12vNcfgRHLSsobeqZFrjFRcVAmFQbDVniguPnEoxmkbG",
"signature": "4isq3qzhY4MwbSeYM2NgRn5noWAyh5rqD12ruiTQ7P89TfXNecwHZ5nbpDc4UB7md1bkfM1xYtSh18FwLqK8HAC6"
}
],
"dataPayload": ""
}
Return field | Type | Description |
---|
version | uint8 | The version of the transaction essence. |
timestamp | int64 | The issuing time of the transaction. |
accessPledgeID | string | The node ID indicating to which node pledge the access mana. |
consensusPledgeID | string | The node ID indicating to which node pledge the consensus mana. |
inputs | []Input | The inputs of the transaction. |
outputs | []Output | The outputs of the transaction. |
unlockBlocks | []UnlockBlock | The unlock block containing signatures unlocking the inputs or references to previous unlock blocks. |
dataPayload | []byte | The raw data payload that can be attached to the transaction. |
Field | Type | Description |
---|
Type | string | The type of input. |
ReferencedOutputID | ReferencedOutputID | The output ID that is used as an input for the transaction. |
Field | Type | Description |
---|
base58 | string | The referenced output identifier encoded with base58. |
transactionID | string | The transaction identifier encoded with base58. |
outputIndex | int | The index of a referenced output. |
Field | Type | Description |
---|
outputID | OutputID | The identifier of an output. |
outputType | string | The type of the output. |
output | string | An output raw block containing balances and corresponding addresses. |
Field | Type | Description |
---|
base58 | string | The output identifier encoded with base58. |
transactionID | string | The transaction identifier encoded with base58. |
outputIndex | int | The index of an output. |
Field | Type | Description |
---|
type | string | The unlock block type: signature or reference. |
referencedIndex | uint16 | The reference index of an unlock block. |
signatureType | uint8 | The unlock block signature type: ED25519 or BLS. |
publicKey | string | The public key of a transaction owner. |
signature | string | The string representation of a signature encoded with base58 signed over a transaction essence. |
Gets a transaction metadata for a given base58 encoded transaction ID.
Parameter | transactionID |
---|
Required or Optional | required |
Description | The transaction ID encoded in base58. |
Type | string |
curl http://localhost:8080/ledgerstate/transactions/:transactionID/metadata \
-X GET \
-H 'Content-Type: application/json'
where :transactionID
is the ID of the conflict, e.g. HuYUAwCeexmBePNXx5rNeJX1zUvUdUUs5LvmRmWe7HCV.
resp, err := goshimAPI.GetTransactionMetadata("41GvDSQnd12e4nWnd2WzmdLmffruXqsE46jgeUbnB8s1QnK")
if err != nil {
// return error
}
fmt.Println("transactionID:", resp.TransactionID)
fmt.Println("conflictID:", resp.ConflictID)
fmt.Printf("conflict lazy booked: %v, solid: %v, finalized: %v\n", resp.LazyBooked, resp.Solid, resp.Finalized)
fmt.Println("solidification time:", time.Unix(resp.SolidificationTime, 0))
{
"transactionID": "HuYUAwCeexmBePNXx5rNeJX1zUvUdUUs5LvmRmWe7HCV",
"conflictID": "HuYUAwCeexmBePNXx5rNeJX1zUvUdUUs5LvmRmWe7HCV",
"solid": true,
"solidificationTime": 1621889358,
"finalized": true,
"lazyBooked": false
}
Return field | Type | Description |
---|
transactionID | string | The transaction identifier encoded with base58. |
conflictID | string | The conflict identifier of the transaction. |
solid | bool | The boolean indicator if the transaction is solid. |
solidificationTime | uint64 | The time of solidification of the transaction. |
finalized | bool | The boolean indicator if the transaction is finalized. |
lazyBooked | bool | The boolean indicator if the transaction is lazily booked. |
Gets the list of blocks IDs with attachments of the base58 encoded transaction ID.
Parameter | transactionID |
---|
Required or Optional | required |
Description | The transaction ID encoded in base58. |
Type | string |
curl http://localhost:8080/ledgerstate/transactions/:transactionID/attachments \
-X GET \
-H 'Content-Type: application/json'
where :transactionID
is the ID of the conflict, e.g. HuYUAwCeexmBePNXx5rNeJX1zUvUdUUs5LvmRmWe7HCV.
resp, err := goshimAPI.GetTransactionAttachments("DNSN8GaCeep6CVuUV6KXAabXkL3bv4PUP4NkTNKoZMqS")
if err != nil {
// return error
}
fmt.Printf("Blocks IDs containing transaction %s:\n", resp.TransactionID)
for _, blkID := range resp.BlockIDs {
fmt.Println(blkID)
}
{
"transactionID": "HuYUAwCeexmBePNXx5rNeJX1zUvUdUUs5LvmRmWe7HCV",
"blockIDs": ["J1FQdMcticXiiuKMbjobq4zrYGHagk2mtTzkVwbqPgSq"]
}
Return field | Type | Description |
---|
transactionID | string | The transaction identifier encoded with base58. |
blockIDs | []string | The blocks IDs that contains the requested transaction. |
Sends transaction provided in form of a binary data, validates transaction before issuing the block payload. For more detail on how to prepare transaction bytes see the tutorial.
Client lib - PostTransaction()
// prepare tx essence and signatures
...
// create transaction
tx := ledgerstate.NewTransaction(txEssence, ledgerstate.UnlockBlocks{unlockBlock})
resp, err := goshimAPI.PostTransaction(tx.Bytes())
if err != nil {
// return error
}
fmt.Println("Transaction sent, txID: ", resp.TransactionID)
Return field | Type | Description |
---|
transactionID | string | The transaction identifier encoded with base58. |
Error | error | The error returned if transaction was not processed correctly, otherwise is nil. |
Gets all unspent outputs for a list of addresses that were sent in the body block. Returns the unspent outputs along with inclusion state and metadata for the wallet.
Request Body
{
"addresses": ["18LhfKUkWt4M9YR6Q3au4LT8wWCERwzHaqn153K78Eixp"]
}
curl http://localhost:8080/ledgerstate/addresses/unspentOutputs \
-X POST \
-H 'Content-Type: application/json'
--data-raw '{"addresses": ["18LhfKUkWt4M9YR6Q3au4LT8wWCERwzHaqn153K78Eixp"]}'
Client lib - PostAddressUnspentOutputs()
resp, err := goshimAPI.PostAddressUnspentOutputs([]string{"H36sZQkopfoEzP3WCMThSjUv5v9MLVYuaQ73tsKgVzXo"})
if err != nil {
return
}
for _, outputs := range resp.UnspentOutputs {
fmt.Println("address ID:", outputs.Address.Base58)
fmt.Println("address type:", outputs.Address.Type)
for _, output := range outputs.Outputs {
fmt.Println("output ID:", output.Output.OutputID.Base58)
fmt.Println("output type:", output.Output.Type)
}
}
{
"unspentOutputs": [
{
"address": {
"type": "AddressTypeED25519",
"base58": "1Z4t5KEKU65fbeQCbNdztYTB1B4Cdxys1XRzTFrmvAf3"
},
"outputs": [
{
"output": {
"outputID": {
"base58": "4eGoQWG7UDtBGK89vENQ5Ea1N1b8xF26VD2F8nigFqgyx5m",
"transactionID": "BqzgVk4yY9PDZuDro2mvT36U52ZYbJDfM41Xng3yWoQK",
"outputIndex": 0
},
"type": "SigLockedColoredOutputType",
"output": {
"balances": {
"11111111111111111111111111111111": 1000000
},
"address": "1Z4t5KEKU65fbeQCbNdztYTB1B4Cdxys1XRzTFrmvAf3"
}
},
"confirmationState": {
"confirmed": true,
"rejected": false,
"conflicting": false
},
"metadata": {
"timestamp": "2021-05-25T15:47:04.50470213+02:00"
}
}
]
}
]
}
Return field | Type | Description |
---|
unspentOutputs | WalletOutputsOnAddress | Unspent outputs representation for wallet. |
Return field | Type | Description |
---|
Address | Address | The address corresponding to the unspent output. |
Outputs | []WalletOutput | Unspent outputs representation for wallet. |
Field | Type | Description |
---|
type | string | The type of an address. |
base58 | string | The address encoded with base58. |
Field | Type | Description |
---|
output | Output | The unspent output. |
confirmationState | ConfirmationState | The inclusion state of the transaction containing the output. |
metadata | WalletOutputMetadata | The metadata of the output for the wallet lib. |
Field | Type | Description |
---|
outputID | OutputID | The identifier of an output. |
outputType | string | The type of the output. |
output | string | An outputs raw block containing balances and corresponding addresses |
Field | Type | Description |
---|
base58 | string | The output identifier encoded with base58. |
transactionID | string | The transaction identifier encoded with base58. |
outputIndex | int | The index of an output. |
Field | Type | Description |
---|
confirmed | bool | The boolean indicating if the transaction containing the output is confirmed. |
rejected | bool | The boolean indicating if the transaction that contains the output was rejected and is booked to the rejected conflict. |
conflicting | bool | The boolean indicating if the output is in conflicting transaction. |
Field | Type | Description |
---|
timestamp | time.Time | The timestamp of the transaction containing the output. |