Transactions

We found this useful within extrinsic construction in our Substrate client, so if you find this useful too, feel free to use scale codec transactions, currently only for writes:

struct MyCustomType {
   let string: String
   let int: Int32
}

struct MyAnotherType {
   let timeMs: Int64
   let randomString: String = UUID().uuidString
}

let coder: ScaleCoder
let customType: MyCustomType
let anotherType: MyAnotherType

let result: Data = try coder.transaction()
        .append(customType.string)
        .append(anotherType.timeMs)
        .append(anotherType.randomString)
        .append(customType.int)
        .commit()

Last updated