Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions bindings/go/examples/dry_run_bytes/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Copyright (c) 2025 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

package main

import (
"log"

sdk "bindings/iota_sdk_ffi"
)

func main() {
client := sdk.GraphQlClientNewDevnet()

txBytesBase64 := "AAACACAAAKSYS9SV1DRvogjd/09dXlrUjCHexjHd68mYCfFpAAAIAPIFKgEAAAACAgABAQEAAQECAAABAABhGDDTZBpo+UppDcwl0fSw2slIMlrBj23TJWQ3FzXzLAILAnDunSfaDbCWUeX3M436MsfuZEHM76H24wVzW8/Hq3M6MhwAAAAAIKlI7704HwxEKcAJUDavYxFuJgvpsFwQktqa3/trEI4n0EB3/jtvrROz1O0NU1t8qSr8rI8PKg4JJfufTwswxplyOjIcAAAAACBwo4RInFHkslDFUznEltYw/OPcH4EFo0/At7kMLZpocGEYMNNkGmj5SmkNzCXR9LDayUgyWsGPbdMlZDcXNfMs6AMAAAAAAACgLS0AAAAAAAA="
transaction, err := sdk.TransactionNewFromBase64(txBytesBase64)
if err != nil {
log.Fatalf("Failed to parse transaction: %v", err)
}

skipChecks := false
res, err := client.DryRunTx(transaction, &skipChecks)
if err.(*sdk.SdkFfiError) != nil {
log.Fatalf("Failed to dry run transaction: %v", err)
}

if res.Error != nil {
log.Fatalf("Dry run failed: %v", *res.Error)
}

log.Print("Dry run was successful!")
log.Printf("Dry run result: %+v", res)
}
2 changes: 1 addition & 1 deletion bindings/go/examples/gas_sponsor/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func main() {
log.Fatalf("Failed to create transaction: %v", err)
}

txnBytes, err := txn.BcsSerialize()
txnBytes, err := txn.ToBytes()
if err != nil {
log.Fatalf("Failed to serialize transaction: %v", err)
}
Expand Down
2 changes: 1 addition & 1 deletion bindings/go/examples/prepare_merge_coins/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func main() {
log.Fatalf("Failed to create transaction: %v", err)
}

txnBytes, err := txn.BcsSerialize()
txnBytes, err := txn.ToBytes()
if err != nil {
log.Fatalf("Failed to serialize transaction: %v", err)
}
Expand Down
2 changes: 1 addition & 1 deletion bindings/go/examples/prepare_send_coins/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func main() {
log.Fatalf("Failed to create transaction: %v", err)
}

txnBytes, err := txn.BcsSerialize()
txnBytes, err := txn.ToBytes()
if err != nil {
log.Fatalf("Failed to serialize transaction: %v", err)
}
Expand Down
2 changes: 1 addition & 1 deletion bindings/go/examples/prepare_send_iota/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func main() {
log.Fatalf("Failed to create transaction: %v", err)
}

txnBytes, err := txn.BcsSerialize()
txnBytes, err := txn.ToBytes()
if err != nil {
log.Fatalf("Failed to serialize transaction: %v", err)
}
Expand Down
2 changes: 1 addition & 1 deletion bindings/go/examples/prepare_send_iota_multi/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func main() {
log.Fatalf("Failed to create transaction: %v", err)
}

txnBytes, err := txn.BcsSerialize()
txnBytes, err := txn.ToBytes()
if err != nil {
log.Fatalf("Failed to serialize transaction: %v", err)
}
Expand Down
2 changes: 1 addition & 1 deletion bindings/go/examples/prepare_split_coins/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func main() {
log.Fatalf("Failed to create transaction: %v", err)
}

txnBytes, err := txn.BcsSerialize()
txnBytes, err := txn.ToBytes()
if err != nil {
log.Fatalf("Failed to serialize transaction: %v", err)
}
Expand Down
2 changes: 1 addition & 1 deletion bindings/go/examples/prepare_transfer_objects/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func main() {
log.Fatalf("Failed to create transaction: %v", err)
}

txnBytes, err := txn.BcsSerialize()
txnBytes, err := txn.ToBytes()
if err != nil {
log.Fatalf("Failed to serialize transaction: %v", err)
}
Expand Down
117 changes: 96 additions & 21 deletions bindings/go/iota_sdk_ffi/iota_sdk_ffi.go
Original file line number Diff line number Diff line change
Expand Up @@ -3536,15 +3536,6 @@ func uniffiCheckChecksums() {
}
}
{
checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t {
return C.uniffi_iota_sdk_ffi_checksum_method_transaction_bcs_serialize()
})
if checksum != 39185 {
// If this happens try cleaning and rebuilding your project
panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_method_transaction_bcs_serialize: UniFFI API checksum mismatch")
}
}
{
checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t {
return C.uniffi_iota_sdk_ffi_checksum_method_transaction_digest()
})
Expand Down Expand Up @@ -3599,6 +3590,24 @@ func uniffiCheckChecksums() {
}
}
{
checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t {
return C.uniffi_iota_sdk_ffi_checksum_method_transaction_to_base64()
})
if checksum != 60127 {
// If this happens try cleaning and rebuilding your project
panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_method_transaction_to_base64: UniFFI API checksum mismatch")
}
}
{
checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t {
return C.uniffi_iota_sdk_ffi_checksum_method_transaction_to_bytes()
})
if checksum != 46058 {
// If this happens try cleaning and rebuilding your project
panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_method_transaction_to_bytes: UniFFI API checksum mismatch")
}
}
{
checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t {
return C.uniffi_iota_sdk_ffi_checksum_method_transactionbuilder_dry_run()
})
Expand Down Expand Up @@ -6569,6 +6578,24 @@ func uniffiCheckChecksums() {
}
}
{
checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t {
return C.uniffi_iota_sdk_ffi_checksum_constructor_transaction_new_from_base64()
})
if checksum != 623 {
// If this happens try cleaning and rebuilding your project
panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_constructor_transaction_new_from_base64: UniFFI API checksum mismatch")
}
}
{
checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t {
return C.uniffi_iota_sdk_ffi_checksum_constructor_transaction_new_from_bytes()
})
if checksum != 60971 {
// If this happens try cleaning and rebuilding your project
panic("iota_sdk_ffi: uniffi_iota_sdk_ffi_checksum_constructor_transaction_new_from_bytes: UniFFI API checksum mismatch")
}
}
{
checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t {
return C.uniffi_iota_sdk_ffi_checksum_constructor_transactionbuilder_init()
})
Expand Down Expand Up @@ -21537,13 +21564,16 @@ func (_ FfiDestroyerSystemPackage) Destroy(value *SystemPackage) {
// transaction-v1 = transaction-kind address gas-payment transaction-expiration
// ```
type TransactionInterface interface {
BcsSerialize() ([]byte, error)
Digest() *Digest
Expiration() TransactionExpiration
GasPayment() GasPayment
Kind() *TransactionKind
Sender() *Address
SigningDigest() []byte
// Serialize the transaction as a base64-encoded string.
ToBase64() (string, error)
// Serialize the transaction as a `Vec<u8>` of BCS bytes.
ToBytes() ([]byte, error)
}
// A transaction
//
Expand All @@ -21566,25 +21596,34 @@ func NewTransaction(kind *TransactionKind, sender *Address, gasPayment GasPaymen
}


// Deserialize a transaction from a base64-encoded string.
func TransactionNewFromBase64(bytes string) (*Transaction, error) {
_uniffiRV, _uniffiErr := rustCallWithError[SdkFfiError](FfiConverterSdkFfiError{},func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer {
return C.uniffi_iota_sdk_ffi_fn_constructor_transaction_new_from_base64(FfiConverterStringINSTANCE.Lower(bytes),_uniffiStatus)
})
if _uniffiErr != nil {
var _uniffiDefaultValue *Transaction
return _uniffiDefaultValue, _uniffiErr
} else {
return FfiConverterTransactionINSTANCE.Lift(_uniffiRV), nil
}
}


func (_self *Transaction) BcsSerialize() ([]byte, error) {
_pointer := _self.ffiObject.incrementPointer("*Transaction")
defer _self.ffiObject.decrementPointer()
_uniffiRV, _uniffiErr := rustCallWithError[SdkFfiError](FfiConverterSdkFfiError{},func(_uniffiStatus *C.RustCallStatus) RustBufferI {
return GoRustBuffer {
inner: C.uniffi_iota_sdk_ffi_fn_method_transaction_bcs_serialize(
_pointer,_uniffiStatus),
}
// Deserialize a transaction from a `Vec<u8>` of BCS bytes.
func TransactionNewFromBytes(bytes []byte) (*Transaction, error) {
_uniffiRV, _uniffiErr := rustCallWithError[SdkFfiError](FfiConverterSdkFfiError{},func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer {
return C.uniffi_iota_sdk_ffi_fn_constructor_transaction_new_from_bytes(FfiConverterBytesINSTANCE.Lower(bytes),_uniffiStatus)
})
if _uniffiErr != nil {
var _uniffiDefaultValue []byte
var _uniffiDefaultValue *Transaction
return _uniffiDefaultValue, _uniffiErr
} else {
return FfiConverterBytesINSTANCE.Lift(_uniffiRV), nil
return FfiConverterTransactionINSTANCE.Lift(_uniffiRV), nil
}
}



func (_self *Transaction) Digest() *Digest {
_pointer := _self.ffiObject.incrementPointer("*Transaction")
defer _self.ffiObject.decrementPointer()
Expand Down Expand Up @@ -21644,6 +21683,42 @@ func (_self *Transaction) SigningDigest() []byte {
}
}))
}

// Serialize the transaction as a base64-encoded string.
func (_self *Transaction) ToBase64() (string, error) {
_pointer := _self.ffiObject.incrementPointer("*Transaction")
defer _self.ffiObject.decrementPointer()
_uniffiRV, _uniffiErr := rustCallWithError[SdkFfiError](FfiConverterSdkFfiError{},func(_uniffiStatus *C.RustCallStatus) RustBufferI {
return GoRustBuffer {
inner: C.uniffi_iota_sdk_ffi_fn_method_transaction_to_base64(
_pointer,_uniffiStatus),
}
})
if _uniffiErr != nil {
var _uniffiDefaultValue string
return _uniffiDefaultValue, _uniffiErr
} else {
return FfiConverterStringINSTANCE.Lift(_uniffiRV), nil
}
}

// Serialize the transaction as a `Vec<u8>` of BCS bytes.
func (_self *Transaction) ToBytes() ([]byte, error) {
_pointer := _self.ffiObject.incrementPointer("*Transaction")
defer _self.ffiObject.decrementPointer()
_uniffiRV, _uniffiErr := rustCallWithError[SdkFfiError](FfiConverterSdkFfiError{},func(_uniffiStatus *C.RustCallStatus) RustBufferI {
return GoRustBuffer {
inner: C.uniffi_iota_sdk_ffi_fn_method_transaction_to_bytes(
_pointer,_uniffiStatus),
}
})
if _uniffiErr != nil {
var _uniffiDefaultValue []byte
return _uniffiDefaultValue, _uniffiErr
} else {
return FfiConverterBytesINSTANCE.Lift(_uniffiRV), nil
}
}
func (object *Transaction) Destroy() {
runtime.SetFinalizer(object, nil)
object.ffiObject.destroy()
Expand Down
51 changes: 42 additions & 9 deletions bindings/go/iota_sdk_ffi/iota_sdk_ffi.h
Original file line number Diff line number Diff line change
Expand Up @@ -4154,9 +4154,14 @@ void uniffi_iota_sdk_ffi_fn_free_transaction(void* ptr, RustCallStatus *out_stat
void* uniffi_iota_sdk_ffi_fn_constructor_transaction_new(void* kind, void* sender, RustBuffer gas_payment, RustBuffer expiration, RustCallStatus *out_status
);
#endif
#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_TRANSACTION_BCS_SERIALIZE
#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_TRANSACTION_BCS_SERIALIZE
RustBuffer uniffi_iota_sdk_ffi_fn_method_transaction_bcs_serialize(void* ptr, RustCallStatus *out_status
#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CONSTRUCTOR_TRANSACTION_NEW_FROM_BASE64
#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CONSTRUCTOR_TRANSACTION_NEW_FROM_BASE64
void* uniffi_iota_sdk_ffi_fn_constructor_transaction_new_from_base64(RustBuffer bytes, RustCallStatus *out_status
);
#endif
#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CONSTRUCTOR_TRANSACTION_NEW_FROM_BYTES
#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CONSTRUCTOR_TRANSACTION_NEW_FROM_BYTES
void* uniffi_iota_sdk_ffi_fn_constructor_transaction_new_from_bytes(RustBuffer bytes, RustCallStatus *out_status
);
#endif
#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_TRANSACTION_DIGEST
Expand Down Expand Up @@ -4189,6 +4194,16 @@ void* uniffi_iota_sdk_ffi_fn_method_transaction_sender(void* ptr, RustCallStatus
RustBuffer uniffi_iota_sdk_ffi_fn_method_transaction_signing_digest(void* ptr, RustCallStatus *out_status
);
#endif
#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_TRANSACTION_TO_BASE64
#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_TRANSACTION_TO_BASE64
RustBuffer uniffi_iota_sdk_ffi_fn_method_transaction_to_base64(void* ptr, RustCallStatus *out_status
);
#endif
#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_TRANSACTION_TO_BYTES
#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_METHOD_TRANSACTION_TO_BYTES
RustBuffer uniffi_iota_sdk_ffi_fn_method_transaction_to_bytes(void* ptr, RustCallStatus *out_status
);
#endif
#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CLONE_TRANSACTIONBUILDER
#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_FN_CLONE_TRANSACTIONBUILDER
void* uniffi_iota_sdk_ffi_fn_clone_transactionbuilder(void* ptr, RustCallStatus *out_status
Expand Down Expand Up @@ -7532,12 +7547,6 @@ uint16_t uniffi_iota_sdk_ffi_checksum_method_systempackage_modules(void
#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_SYSTEMPACKAGE_VERSION
uint16_t uniffi_iota_sdk_ffi_checksum_method_systempackage_version(void

);
#endif
#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_TRANSACTION_BCS_SERIALIZE
#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_TRANSACTION_BCS_SERIALIZE
uint16_t uniffi_iota_sdk_ffi_checksum_method_transaction_bcs_serialize(void

);
#endif
#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_TRANSACTION_DIGEST
Expand Down Expand Up @@ -7574,6 +7583,18 @@ uint16_t uniffi_iota_sdk_ffi_checksum_method_transaction_sender(void
#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_TRANSACTION_SIGNING_DIGEST
uint16_t uniffi_iota_sdk_ffi_checksum_method_transaction_signing_digest(void

);
#endif
#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_TRANSACTION_TO_BASE64
#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_TRANSACTION_TO_BASE64
uint16_t uniffi_iota_sdk_ffi_checksum_method_transaction_to_base64(void

);
#endif
#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_TRANSACTION_TO_BYTES
#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_TRANSACTION_TO_BYTES
uint16_t uniffi_iota_sdk_ffi_checksum_method_transaction_to_bytes(void

);
#endif
#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_METHOD_TRANSACTIONBUILDER_DRY_RUN
Expand Down Expand Up @@ -9554,6 +9575,18 @@ uint16_t uniffi_iota_sdk_ffi_checksum_constructor_systempackage_new(void
#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_CONSTRUCTOR_TRANSACTION_NEW
uint16_t uniffi_iota_sdk_ffi_checksum_constructor_transaction_new(void

);
#endif
#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_CONSTRUCTOR_TRANSACTION_NEW_FROM_BASE64
#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_CONSTRUCTOR_TRANSACTION_NEW_FROM_BASE64
uint16_t uniffi_iota_sdk_ffi_checksum_constructor_transaction_new_from_base64(void

);
#endif
#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_CONSTRUCTOR_TRANSACTION_NEW_FROM_BYTES
#define UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_CONSTRUCTOR_TRANSACTION_NEW_FROM_BYTES
uint16_t uniffi_iota_sdk_ffi_checksum_constructor_transaction_new_from_bytes(void

);
#endif
#ifndef UNIFFI_FFIDEF_UNIFFI_IOTA_SDK_FFI_CHECKSUM_CONSTRUCTOR_TRANSACTIONBUILDER_INIT
Expand Down
26 changes: 26 additions & 0 deletions bindings/kotlin/examples/DryRunBytes.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright (c) 2025 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

import iota_sdk.*
import kotlinx.coroutines.runBlocking

fun main() = runBlocking {
try {
val client = GraphQlClient.newDevnet()

val txBytesBase64 =
"AAACACAAAKSYS9SV1DRvogjd/09dXlrUjCHexjHd68mYCfFpAAAIAPIFKgEAAAACAgABAQEAAQECAAABAABhGDDTZBpo+UppDcwl0fSw2slIMlrBj23TJWQ3FzXzLAILAnDunSfaDbCWUeX3M436MsfuZEHM76H24wVzW8/Hq3M6MhwAAAAAIKlI7704HwxEKcAJUDavYxFuJgvpsFwQktqa3/trEI4n0EB3/jtvrROz1O0NU1t8qSr8rI8PKg4JJfufTwswxplyOjIcAAAAACBwo4RInFHkslDFUznEltYw/OPcH4EFo0/At7kMLZpocGEYMNNkGmj5SmkNzCXR9LDayUgyWsGPbdMlZDcXNfMs6AMAAAAAAACgLS0AAAAAAAA="
val transaction = Transaction.newFromBase64(txBytesBase64)

val res = client.dryRunTx(transaction, false)

if (res.error != null) {
throw Exception("Dry run failed: ${res.error}")
}

println("Dry run was successful!")
println("Dry run result: $res")
} catch (e: Exception) {
e.printStackTrace()
}
}
2 changes: 1 addition & 1 deletion bindings/kotlin/examples/GasSponsor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ fun main() = runBlocking {
val txn = builder.finish()

println("Signing Digest: ${hexEncode(txn.signingDigest())}")
println("Txn Bytes: ${base64Encode(txn.bcsSerialize())}")
println("Txn Bytes: ${base64Encode(txn.toBytes())}")

val res = client.dryRunTx(txn, false)

Expand Down
Loading