Type
CONTRACT
Validation date
2024-11-15 10:17:20 UTC
Fee
0 UCO

Code (1.26 KB)

@version 1

condition triggered_by: transaction, on: refund(), as: [
  content: (
    valid? = false

    abi_data = Evm.abi_encode("status()")
    tx = [to: "0x18B21C100409eAE5Fb734fB6b5299dFba276D288", 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)

    evm_responses = query_evm_apis(["https://polygon-mainnet.infura.io/v3/3a7a2dbdbec046a4961550ddf8c7d78a","https://polygon-mainnet.g.alchemy.com/v2/0aM2uAp3J-LsOlijDBZ3aZiCUvZdjiHb"], "POST", headers, body)
    for res in evm_responses do
      if !valid? && 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)
          # Refund status is 2
          valid? = List.at(decoded_abi, 0) == 2
        end
      end
    end

    valid?
  )
]

actions triggered_by: transaction, on: refund() do
  Contract.set_type "transfer"
  # Send back UCO to bridge pool
Contract.add_uco_transfer to: 0x00002075E9FB5329C7F5149802EB75F925D79B5FEC5BFCF09DC81993CB9C39FEAF5D, amount: 1006.88255315


  Contract.set_code """
  @version 1

  export fun info() do
    [
      evm_contract: 0x18B21C100409eAE5Fb734fB6b5299dFba276D288,
      evm_pool: 0xd5ca9f76495b853a5054814a10b6365ee8ed745b,
      ae_pool: 0x00002075E9FB5329C7F5149802EB75F925D79B5FEC5BFCF09DC81993CB9C39FEAF5D,
      status: 2 # REFUNDED
    ]
  end
  """
end

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

    abi_data = Evm.abi_encode("status()")
    tx = [to: "0x18B21C100409eAE5Fb734fB6b5299dFba276D288", 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)

    responses = query_evm_apis(["https://polygon-mainnet.infura.io/v3/3a7a2dbdbec046a4961550ddf8c7d78a","https://polygon-mainnet.g.alchemy.com/v2/0aM2uAp3J-LsOlijDBZ3aZiCUvZdjiHb"], "POST", headers, body)
    for res in responses do
      if !valid? && 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
    end

    valid?
  )
]

actions triggered_by: transaction, on: reveal_secret(secret) do
  Contract.set_type "transfer"
  Contract.add_uco_transfer to: 0x0000F199462325353B134DDD6C45DCA147DA0AE2D5B2611CEE0107D1D1F123314D00, amount: 1006.88255315


  Contract.set_code """
  @version 1

  export fun info() do
    [
      evm_contract: 0x18B21C100409eAE5Fb734fB6b5299dFba276D288,
      evm_pool: 0xd5ca9f76495b853a5054814a10b6365ee8ed745b,
      ae_pool: 0x00002075E9FB5329C7F5149802EB75F925D79B5FEC5BFCF09DC81993CB9C39FEAF5D,
      status: 1 # WITHDRAWN
    ]
  end
  """
end

fun query_evm_apis(endpoints, method, headers, body) do
  requests = []
  for endpoint in endpoints do
    requests = List.append(requests, url: endpoint, method: method, headers: headers, body: body)
  end
  Http.request_many(requests, false)
end

export fun get_provision_signature() do
  [
    r: 0xFD48F364CC5D6BB9D998E5CEE143CDA7EDE680EE8C27A498372A6E0C4D81373A,
    s: 0x4F072C25F91A30F37A8D0D765328E76E90A7999BA74F7FD02CC4B74C260D305B,
    v: 27
  ]
end

export fun info() do
  [
    evm_contract: 0x18B21C100409eAE5Fb734fB6b5299dFba276D288,
    evm_pool: 0xd5ca9f76495b853a5054814a10b6365ee8ed745b,
    ae_pool: 0x00002075E9FB5329C7F5149802EB75F925D79B5FEC5BFCF09DC81993CB9C39FEAF5D,
    status: 0 # PENDING
  ]
end

Content (0 B)

State (0 B)

Movements (0)

Ownerships (1)

  • Secret shared with 1 key

    Encoded secret

    D7D9C99A66DD96E6FDC4F0186B1AC7AA35896BEADCAB8E0EAD71713163DCAD6CF6E1DF3815746BA401E266E2CDD1395A3FD374B2C4B69DA03180A024

    Authorized keys

    • 000122A6CD9ED07E46835D6E88E5BD0BEE84C3F5E5DBF8E916AD9B2EC912C44AFEC2

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

0001F2C3224A34DF4F21A438D69682BE75CC2312EA2F18D194110F1AF17B05B9BC82

Previous signature

A69C7723D84616FC0E69F98E7CEC8D628847F6AFF4249AD03393A4F601C543A011740EF6A521B48FACDC65C6FF284565B7E66DF7C09BF0B3719EFFC180880100

Origin signature

3045022100F0F0B0C88434903357ED9A79454680C9C3E2E3D729EB63ED2D9DDF4A5DD3A05802207EBCAE3AEF3E8D0831140DB947FE25913F8E03BD4D5F035BC008B03016C3B76B

Proof of work

010204480DD0A3F06534B4F9B9D93AC3BCC7EA8437BAE24295DBCB92035EE4E5C7AC86DE42699A2F1481F9F892D528363680AF126B34DADED27CFC5CF4F778B7027D14

Proof of integrity

00B8FDD82F19980A2112761E8C7EA30BC6ABFFCB05C2AA2FFEA6B8568087FCBED7

Coordinator signature

476E1F13341C9C6B26E744545E1A65E4B8B71285A82F1C88E33EAB7FB1AF282A699B82608642EFCBE19A1F1E1ED0828E081ADC2DE67FE9BB9D8245C967CB850D

Validator #1 public key

0001B9E2941895A3951F10CE0D7978DD083C3D8A19ACE27F4F98798DF04045B11181

Validator #1 signature

5FB585AD6D064E33DFF320BB0E3BAED79909A6359505A18EC7FAB74AF08CCA888336FB1DE37865D5933F23EDEC1FBDD337CDAFD91A647A1BBD648C85AFF1D307

Validator #2 public key

0001172FBEC021CA921A9A771C312FCAD74E84CF0A466F5F662630C70E7BD8699587

Validator #2 signature

8345216E7E32A630459FB60284E4292B1D43A5491F6F8BF26DD5BA23B9E5E5FCB7DBDDB9932B16C72C74C0B528DFA3C82D89CA9185A694AAEF302FAD892FA502