@version 1
condition triggered_by: transaction, on: set_secret_hash(_secret_hash, _secret_hash_signature, _end_time), as: [
previous_public_key: (
# Transaction is not yet validated so we need to use previous address
# to get the genesis address
previous_address = Chain.get_previous_address()
Chain.get_genesis_address(previous_address) == 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801
)
]
actions triggered_by: transaction, on: set_secret_hash(secret_hash, secret_hash_signature, end_time) do
next_code = """
@version 1
# Automate the refunding after the given timestamp
actions triggered_by: datetime, at: #{end_time} do
Contract.set_type "transfer"
# Send back the token to the user address
Contract.add_uco_transfer to: 0x0000B05DE7312129A8F7C397BC359506896A90A87C88DC54C9023D23EFC9BF5A8773, amount: 2
Contract.set_code ""
end
condition triggered_by: transaction, on: refund(), as: [
timestamp: timestamp >= #{end_time}
]
actions triggered_by: transaction, on: refund() do
Contract.set_type "transfer"
# Send back the token to the user address
Contract.add_uco_transfer to: 0x0000B05DE7312129A8F7C397BC359506896A90A87C88DC54C9023D23EFC9BF5A8773, amount: 2
Contract.set_code ""
end
condition triggered_by: transaction, on: reveal_secret(secret, secret_signature), as: [
previous_public_key: (
# Transaction is not yet validated so we need to use previous address
# to get the genesis address
previous_address = Chain.get_previous_address()
Chain.get_genesis_address(previous_address) == 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801
),
timestamp: transaction.timestamp < #{end_time},
content: Crypto.hash(String.to_hex(secret)) == 0x#{secret_hash}
]
actions triggered_by: transaction, on: reveal_secret(secret, secret_signature) do
next_code = """
@version 1
export fun get_secret() do
[
secret: 0x\#{secret},
secret_signature: [
r: 0x\#{secret_signature.r},
s: 0x\#{secret_signature.s},
v: \#{secret_signature.v}
]
]
end
\"""
Contract.set_type "transfer"
Contract.add_uco_transfer to: 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801, amount: 1.994
Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.006
Contract.set_code next_code
end
export fun get_htlc_data() do
[
amount: 1.994,
end_time: #{end_time},
secret_hash: 0x#{secret_hash},
secret_hash_signature: [
r: 0x#{secret_hash_signature.r},
s: 0x#{secret_hash_signature.s},
v: #{secret_hash_signature.v}
]
]
end
"""
Contract.set_code next_code
end
Content (0 B)
State (0 B)
-
Secret shared with 1 key
Encoded secret
7CF9FEDD8EEA16050630E17192B07F61DA7914DC930E727BC7958989349FABFC6B6573595454CAEFD6C85FF6174F0BEA0B7C29CA8235E8A405DA14F8
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
Contract recipients (0)
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 0000AF22...9B7BAt 2023-12-01 16:09:45 UTCAmount 0.42920841 UCO
Previous public key
0001AD5407D36B7B8DB4072ACFC906287DAA752768E17C866EA65289E0559CF1E346
Previous signature
CB66397A5419BC41FFD3229FE291A7A70355484649ACBA1C10D27857C3A98FA74564E2E8179A81591491418BB565D596F7E0CCE765C9B27CD374936EB292AD0E
Origin signature
3044022056AD78674ED408E2E10076C0BA2E81B8438B53427C57832F8D3B59509EEBFC3C0220653055EF5FAB52F1EC2C60688773D040E5AC4D6B525F4036FEDE9205E2054211
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
006AA9BA72AE5D78587F49AE13B798F69CC74F33F588C74F6FE19AB534A582EB40
Coordinator signature
D1121E0D9C899E66AF3BF51A67B55490E4FD4163F468F3DF163B5D6986836866C497505B265E820F0AD8C9130FCCF7D2E71EF8848D49B5F1457879AC0844EA0C
Validator #1 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #1 signature
E1CE13847019E57B5835208AB1B73E1A10ADC8DB177073A3746BB05A25D6E02F0756CF580255CE7FFB78DC479EC80F22220A0582F919219C3E4B99B77A4F5E0F
Validator #2 public key
000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF
Validator #2 signature
8A17CE32BA823FF01F5BFAB6550D5EE90FD86AAFD737F0963601B27142537FA87A43C20269916D2FEDC29895BF9328A33EEAF4467850498775A62F3D6507430A