Type
CONTRACT
Validation date
2024-01-30 18:07:12 UTC
Fee
0.77314969 UCO

Code (1.06 KB)

@version 1

condition triggered_by: transaction, on: provision(_evm_contract, _url), 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) == 0x000066706D704329CA8C2A4153991E2DDACC968622CA10217CA14952EB7ABB966C30
 )
]

actions triggered_by: transaction, on: provision(evm_contract, url) do
  next_code = """
    @version 1

  # Automate the refunding after the given timestamp
  actions triggered_by: datetime, at: 1706644980 do
    Contract.set_type "transfer"
    # Burn the non withdrawed tokens
  Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 4.975, token_address: 0x00003DF600E329199BF3EE8FBE2B8223413D70BCDD97E15089E6A74D94DE3F1173B4

    Contract.set_code ""
  end

  condition triggered_by: transaction, on: refund(), as: [
    timestamp: timestamp >= 1706644980
  ]

  actions triggered_by: transaction, on: refund() do
    Contract.set_type "transfer"
    # Burn the non withdrawed tokens
  Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 4.975, token_address: 0x00003DF600E329199BF3EE8FBE2B8223413D70BCDD97E15089E6A74D94DE3F1173B4

    Contract.set_code ""
  end

  condition triggered_by: transaction, on: reveal_secret(secret), as: [
    content: Crypto.hash(String.to_hex(secret)) == 0x83ACC5845B21DDE7E05B33778B1D506B92B63FA8FF418E8DD31E3F49AEC45F2D,
    address: (
      valid? = false

      abi_data = Evm.abi_encode("status()")
      tx = [to: "#{evm_contract}", data: "0x\#{abi_data}"]
      request = [jsonrpc: "2.0", id: "1", method: "eth_call", params: [tx, "latest"]]

      headers = ["Content-Type": "application/json"]
      body = Json.to_string(request)

      res = Http.request("#{url}", "POST", headers, body)
      if res.status == 200 && Json.is_valid?(res.body) do
        response = Json.parse(res.body)
        result = Map.get(response, "result")
        
        if result != nil do
          decoded_abi = Evm.abi_decode("(uint)", result)
          # Withdrawn status is 1
          valid? = List.at(decoded_abi, 0) == 1
        end
      end

      valid?
    )
  ]

  actions triggered_by: transaction, on: reveal_secret(secret) do
    Contract.set_type "transfer"
    Contract.add_token_transfer to: 0x0000834AD179A291856494A6ECA9AA855AAE0F28E5F221666CBD11D2FF96B2A0FE19, amount: 4.960075, token_address: 0x00003DF600E329199BF3EE8FBE2B8223413D70BCDD97E15089E6A74D94DE3F1173B4
  Contract.add_token_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.014925, token_address: 0x00003DF600E329199BF3EE8FBE2B8223413D70BCDD97E15089E6A74D94DE3F1173B4

    Contract.set_code ""
  end

  """

  Contract.set_code next_code
end

Content (0 B)

State (0 B)

Movements (0)

Ownerships (1)

  • Secret shared with 1 key

    Encoded secret

    20C234312C34A8E61F1E2B34EC69567A551C662F3ED68FAF7861BB4B8EEC0A32CDD1CFD381D31D246870AEDD7EFA70F9751FA188EDE0585C77BFA41E

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (1)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

0001911AAC8E3DBF4FD35D59D53F9F9CA82D94BB76F0864378DF48BB4A1D6963DF28

Previous signature

418B89EF0C67E311A9C3208950A1D611FD5AABF7245771EAFF01276908C9F9006ED0771C6CB14A4C22222C91FB0D38F1D0DD002CC2AEF8E28B1CDBA13B4A8F08

Origin signature

3044022054E2A0C8664B5A79F6A87233B3BDCE8309BB713F9B6DBEEF78C6542633819BD30220035AD7FB29C0C5138568D303D916EA1567F25E03C66DC964E289EA56F215BD30

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

00443CD21268B8B4FC267DE7CAC5E5E3F9FCAD621169B9FF4BCED722AF8EF4E74F

Coordinator signature

0C67166BEFE90BC2AE7B4D241A1FDB23F655B32F234B2625ABD0CD74B93764E51FF3BC5DD9E310C3F5F61D67A2DFA55C7D370B0B1F8A6309BE88EB503A331104

Validator #1 public key

0001B01EEF96BA7E95FC844D456CE8868F18864519FC9532E1751C2035FD044DD5D0

Validator #1 signature

7AE044438BA4E260367A5E3C6C4F7920C458922DB3130C72AC70BD13522C2A3D82F593D374E9F36910305390E021798E145E20BADF3416DB7AFAA71747F5B30E

Validator #2 public key

000103E30584AD8DE66F9E29419D5D0ABEE5A76722C9FD0D012BDDE3A6E2B149C48D

Validator #2 signature

8F41251A3B669EF0AB7E70212FDC2A2B548426A1A2A0B83E7830A56A7C5E2F7654FC6F9BBC9CBB5808584C1DFB02F047420AB774A822F970D71F3BA22BE2B103