Type
CONTRACT
Validation date
2024-11-13 14:23:58 UTC
Fee
0.57015419 UCO

Code (901 B)

@version 1

condition triggered_by: transaction, on: set_secret_hash(_secret_hash, _secret_hash_signature, _end_time, _evm_pool), 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, evm_pool) do
  Contract.set_code """
  @version 1

  condition triggered_by: transaction, on: refund(secret, secret_signature), as: [
    previous_public_key: (
      previous_address = Chain.get_previous_address()
      Chain.get_genesis_address(previous_address) == 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801
    ),
    timestamp: timestamp >= #{end_time}
  ]

  actions triggered_by: transaction, on: refund(secret, secret_signature) do
    Contract.set_type "transfer"
    # Send back the token to the user address
    Contract.add_uco_transfer to: 0x00000BC0EBA2DBCE4455B46F5E51AFAABA6EB4C7FBA1D4E2E6DABD55DC70F9A04D6F, amount: 1

    Contract.set_code \"""
    @version 1

    export fun info() do
      [
        evm_pool: #{evm_pool},
        ae_pool: 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801,
        status: 2 # REFUNDED
      ]
    end

    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
    \"""
  end

  condition triggered_by: transaction, on: reveal_secret(secret, secret_signature, _evm_contract), 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, evm_contract) do
    Contract.set_type "transfer"
        Contract.add_uco_transfer to: 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801, amount: 0.997
    Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.003


    Contract.set_code \"""
    @version 1

    export fun info() do
      [
        evm_contract: \#{evm_contract},
        evm_pool: #{evm_pool},
        ae_pool: 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801,
        status: 1 # WITHDRAWN
      ]
    end

    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
    \"""
  end

  export fun info() do
    [
      evm_pool: #{evm_pool},
      ae_pool: 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801,
      status: 0 # PENDING
    ]
  end

  export fun get_htlc_data() do
    [
      amount: 0.997,
      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
  """
end

export fun info() do
  [
    ae_pool: 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801,
    status: 0 # PENDING
  ]
end

Content (0 B)

State (0 B)

Movements (0)

Ownerships (1)

  • Secret shared with 1 key

    Encoded secret

    817A57C100AD024F200172E1658752FBD0A6AA58C300312219CC163E0DFB001A327D069D0B480EC08E2D44252E2A151E53F9F2671B8470F3C12BD998

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

00016EE8E627BB249C5E8D76A316D64AF6C62592D6F69FD49E17693BA41A1D65C59C

Previous signature

910567A369198C1D9AC904EEE065B4C68A11D5EE08F1B1D1921E3D034568D9586B7D1AC3855805614B6B22AC33C976359090B35890961221706646C88043920E

Origin signature

304402205F4D2B27C4100B4FD191B1D6271B86BE0C7AEBC3BB02D581EDA48A95D39515D6022057B5E647D3E2755575C47A76498F854E7B826BCB34613B89D6BCC5BFEEBD4F31

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

00A4C884CE9012B5BDB66B9EE78C6F98A3F8BAC7CD2BB32150ECE26BC9A7963198

Coordinator signature

1D6F9120F187183BB976B8ADFD4B8647DF769B32FDF89E4B5C6F8DD086A0A4992971BD3FE5D4E868748DE4D62BA3815E0D2FA54D3129B4CBBDB7FD72ED763406

Validator #1 public key

00013F0000490CECA80A76E7199D7B53E23583A16E24EF761384EC642713056C33D7

Validator #1 signature

F0ABE95E50499B7B26BD4C2194DCF303E7DA2E85E7CAF4BA33D39277ABD879041D872BC83FF5D12D480F4F67BEAAC10D12470E60F10A715C8FAF460364F40B07

Validator #2 public key

00019C8445BB4870EBD35A7F7776112766B4C78305A410A3B4782FFE0DF2A75E3D8A

Validator #2 signature

EBCEFDE114363FED61B2A5B9A7294586E29F411BE59B7A8CB7B0A60F67C5CD031F08C9AB5DCDB10B32FC1103803D432635FA71C1F28911CD9A1D079F0B6C1400