Revoke Swap transaction redeems the assets and token under swap state back to the sender of the swap. This transaction is useful if the sender wants to stop the atomic swap for whatever reason. But in order to protect the receiver, sender is only allowed to revoke a swap after its locktime.

Protocol definition

message RevokeSwapTx {
  string address = 1;

  google.protobuf.Any data = 15;
  • address is the address of the swap state to revoke.


Here's an example of how to send a revoke swap transaction.

# Declare sender and receiver
sender = ForgeSdk.create_wallet()
ForgeSdk.declare( "alice"), wallet: w)
receiver = ForgeSdk.create_wallet()
ForgeSdk.declare( "bob"), wallet: w)

# Generates a random number as hashkey.
hashkey = :crypto.strong_rand_bytes(32)
# Calculates the sha3 output as hashlock.
hashlock = Mcrypto.hash(%Mcrypto.Hasher.Sha3{}, hashkey)

# Assemble and send the SetupSwapTx
itx =
  value: ForgeAbi.token_to_unit(1),
  assets: [],
  receiver: receiver.address,
  locktime: 1000000,
  hashlock: hashlock
hash = ForgeSdk.setup_swap(itx, wallet: sender, send: :commit)

# Calculates the swap address created by this transaction.
address = ForgeSdk.Util.to_swap_address(hash)

# Assemble and send the RevokeSwapTx
itx = address)
ForgeSdk.revoke_swap(itx, wallet: sender, send: :commit)