Auth
object Auth
Helper class for signing Soroban authorization entries.
This class provides methods to authorize smart contract invocations by:
Signing existing authorization entries (typically from transaction simulation)
Building new authorization entries from scratch
Supporting custom signing logic through the Signer interface
Usage Examples
Authorize an existing entry with a KeyPair
val entry = SorobanAuthorizationEntryXdr.fromXdrBase64("...")
val signer = KeyPair.fromSecretSeed("S...")
val network = Network.TESTNET
val validUntilLedgerSeq = 1000000L
val signedEntry = Auth.authorizeEntry(
entry = entry,
signer = signer,
validUntilLedgerSeq = validUntilLedgerSeq,
network = network
)Content copied to clipboard
Build a new authorization from scratch
val invocation = SorobanAuthorizedInvocationXdr(...)
val signer = KeyPair.fromSecretSeed("S...")
val network = Network.TESTNET
val validUntilLedgerSeq = 1000000L
val authEntry = Auth.authorizeInvocation(
signer = signer,
validUntilLedgerSeq = validUntilLedgerSeq,
invocation = invocation,
network = network
)Content copied to clipboard
Use a custom signer
val customSigner = object : Auth.Signer {
override suspend fun sign(preimage: HashIDPreimageXdr): Auth.Signature {
val payload = Util.hash(preimage.toXdrByteArray())
// Custom signing logic (e.g., hardware wallet)
val signature = myCustomSigningDevice.sign(payload)
return Auth.Signature(publicKey = "G...", signature = signature)
}
}
val signedEntry = Auth.authorizeEntry(
entry = entry,
signer = customSigner,
validUntilLedgerSeq = validUntilLedgerSeq,
network = network
)Content copied to clipboard
See also
Types
Functions
Link copied to clipboard
suspend fun authorizeEntry(entry: SorobanAuthorizationEntryXdr, signer: Auth.Signer, validUntilLedgerSeq: Long, network: Network): SorobanAuthorizationEntryXdr
suspend fun authorizeEntry(entry: String, signer: Auth.Signer, validUntilLedgerSeq: Long, network: Network): SorobanAuthorizationEntryXdr
Authorizes an existing authorization entry using a custom Signer.
suspend fun authorizeEntry(entry: SorobanAuthorizationEntryXdr, signer: KeyPair, validUntilLedgerSeq: Long, network: Network): SorobanAuthorizationEntryXdr
suspend fun authorizeEntry(entry: String, signer: KeyPair, validUntilLedgerSeq: Long, network: Network): SorobanAuthorizationEntryXdr
Authorizes an existing authorization entry using a KeyPair.
Link copied to clipboard
suspend fun authorizeInvocation(signer: KeyPair, validUntilLedgerSeq: Long, invocation: SorobanAuthorizedInvocationXdr, network: Network): SorobanAuthorizationEntryXdr
Builds and authorizes a new entry from scratch using a KeyPair.
suspend fun authorizeInvocation(signer: Auth.Signer, publicKey: String, validUntilLedgerSeq: Long, invocation: SorobanAuthorizedInvocationXdr, network: Network): SorobanAuthorizationEntryXdr
Builds and authorizes a new entry from scratch using a custom Signer.