Bridge API

This page provides a set of APIs to interact with backend.

This API enable users to do all bridge operations.

For flow freely between Harmony and Ethereum blockchains you need to call this methods in special order and with special params.

Operations Example

ETH -> ONE (BUSD)

1) call Create operation API with params (see more params in API section):

  • type= eth_to_one

  • id = operation uniq ID (you need to generate ID on client side)

  • token = busd

  • amount = transfered amount

  • ethAddress = your ethereum address

  • oneAddress = harmony receiver address

2) call approveEthManager smart contract method (see smart contract methods section in the end) for BUSD ethereum contract. You need to save generated transaction hash.

3) call lockToken smart contract method (see smart contract methods section in the end) for BUSD manager ethereum contract. You need to save generated transaction hash.

4) call Confirm action API with params (see more params in API section):

  • operationId - operation ID (generated on step 1)

  • transactionHash - approveEthManager transaction Hash (generated on step 2)

  • actionType = approveEthManager

5) call Confirm action API with params (see more params in API section):

  • operationId - operation ID (generated on step 1)

  • transactionHash - lockToken transaction Hash (generated on step 2)

  • actionType = lockToken

6) call Get Operation Info API with operation ID (generated on step 1) to get actual operation status (see status property).

Also you can monitoring each action status: see operation -> actions

7) Next stepsWait for finality and Mint tokens (on harmony side) - will be done automatically. You need only monitoring operation status (step 6).

For Create operation API and Confirm action API you need to call API for each validator from list.

[
"https://be1.bridge.hmny.io",
"https://be2.bridge.hmny.io",
"https://be3.bridge.hmny.io"
]

ONE -> ETH (BUSD)

1) call Create operation API with params (see more params in API section):

  • type= one_to_eth

  • id = operation uniq ID (you need to generate ID on client side)

  • token = link

  • amount = transfered amount

  • oneAddress = your one address

  • ethAddress = ethereum receiver address

2) call approveHmyManager smart contract method (see smart contract methods section in the end) for BUSD harmony contract. You need to save generated transaction hash.

3) call burnToken smart contract method (see smart contract methods section in the end) for BUSD manager harmony contract. You need to save generated transaction hash.

4) call Confirm action API with params (see more params in API section):

  • operationId - operation ID (generated on step 1)

  • transactionHash - approveHmyManager transaction Hash (generated on step 2)

  • actionType = approveHmyManager

5) call Confirm action API with params (see more params in API section):

  • operationId - operation ID (generated on step 1)

  • transactionHash - burnToken transaction Hash (generated on step 2)

  • actionType = burnToken

6) call Get Operation Info API with operation ID (generated on step 1) to get actual operation status (see status property).

Also you can monitoring each action status: see operation -> actions

7) Next step Unlock tokens (on ethereum side) - will be done automatically. You need only monitoring operation status (step 6).

For Create operation API and Confirm action API you need to call API for each validator from list.

API description

post
Create operation

https://be1.bridge.hmny.io/operations
this method will create new operation - it must be call for each validator (be1, be2, be3)
Request
Response
Request
Body Parameters
id
required
string
id must be generated on client side. id format example: b063040e-31c41b19-a7d21a09-9bb0339f
amount
required
string
displayed amount (use only for explorer display)
token
required
string
link | busd | erc20
type
required
string
eth_to_one | one_to_eth
ethAddress
required
string
this field using depends on operation type: eth_to_one: ethereum sender (who will sign tx) one_to_eth: ethereum receiver (who will get tokens)
oneAddress
required
string
this field using depends on operation type: eth_to_one: harmony receiver (who will get tokens) one_to_eth: harmony sender (who will sign tx)
erc20Address
optional
string
ERC20 address needed only for operations with type erc20
Response
200: OK
Cake successfully retrieved.
{
"id":"7076042e-f23b3018-cfe6195f-b94b75f5",
"type":"eth_to_one",
"erc20Address":"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
"token":"link",
"status":"in_progress",
"amount":"0.1",
"ethAddress":"0x85c016897702a33a1ef58a0755d149ee943e2cd5",
"oneAddress":"one1shqpdzthq23n58h43gr4t52fa62rutx4s247sk",
"timestamp":1603303897,
"actions":[
{
"id":"f70af6bb-2f24915a-7ab56d36-b03bbc5f",
"type":"approveEthManger",
"status":"waiting",
"payload":null
},
{
"id":"88d9cc67-b004e8cc-71020a1b-5e2ba517",
"type":"lockToken",
"status":"waiting",
"payload":null
},
{
"id":"0c2b22b9-94891de9-85088db4-1b9dc3e0",
"type":"waitingBlockNumber",
"status":"waiting",
"payload":null
},
{
"id":"393dabb6-b43a583e-7852a254-61be358a",
"type":"mintToken",
"status":"waiting",
"payload":null
}
]
}
404: Not Found
Could not find a cake matching this query.
{ "error": "error message here"

post
Confirm action

https://be1.bridge.hmny.io/operations/:operationId/actions/:actionType/confirm
Is used for confirm actions instead of process eth_to_one ore one_to_eth
Request
Response
Request
Path Parameters
operationId
required
string
operation Id (was created on frontend side on 1 step)
actionType
required
string
approveEthManager | lockToken |approveHmyManager | burnToken
Body Parameters
transactionHash
required
string
hash of transaction which must be success, for move to next step. you can send transaction in pending status - validator will observe it automatically.
Response
200: OK
{
"id":"7076042e-f23b3018-cfe6195f-b94b75f5",
"type":"eth_to_one",
"erc20Address":"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
"token":"link",
"status":"in_progress",
"amount":"0.1",
"ethAddress":"0x85c016897702a33a1ef58a0755d149ee943e2cd5",
"oneAddress":"one1shqpdzthq23n58h43gr4t52fa62rutx4s247sk",
"timestamp":1603303897,
"actions":[
{
"id":"f70af6bb-2f24915a-7ab56d36-b03bbc5f",
"type":"approveEthManger",
"status":"waiting",
"payload":null
},
{
"id":"88d9cc67-b004e8cc-71020a1b-5e2ba517",
"type":"lockToken",
"status":"waiting",
"payload":null
},
{
"id":"0c2b22b9-94891de9-85088db4-1b9dc3e0",
"type":"waitingBlockNumber",
"status":"waiting",
"payload":null
},
{
"id":"393dabb6-b43a583e-7852a254-61be358a",
"type":"mintToken",
"status":"waiting",
"payload":null
}
]
}

get
Get operation info

https://be1.bridge.hmny.io/operations/:id
Is used for get operation status and actions status (look at actions array in response)
Request
Response
Request
Path Parameters
id
optional
string
operation id
Response
200: OK
{
"id":"7076042e-f23b3018-cfe6195f-b94b75f5",
"type":"eth_to_one",
"erc20Address":"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
"token":"link",
"status":"in_progress",
"amount":"0.1",
"ethAddress":"0x85c016897702a33a1ef58a0755d149ee943e2cd5",
"oneAddress":"one1shqpdzthq23n58h43gr4t52fa62rutx4s247sk",
"timestamp":1603303897,
"actions":[
{
"id":"f70af6bb-2f24915a-7ab56d36-b03bbc5f",
"type":"approveEthManger",
"status":"waiting",
"payload":null
},
{
"id":"88d9cc67-b004e8cc-71020a1b-5e2ba517",
"type":"lockToken",
"status":"waiting",
"payload":null
},
{
"id":"0c2b22b9-94891de9-85088db4-1b9dc3e0",
"type":"waitingBlockNumber",
"status":"waiting",
"payload":null
},
{
"id":"393dabb6-b43a583e-7852a254-61be358a",
"type":"mintToken",
"status":"waiting",
"payload":null
}
]
}
โ€‹

LINKS

Smart contracts ABI and method call examples - here (https://github.com/harmony-one/ethhmy-bridge/tree/master/scripts)

You can see more examples of API using without UI here: https://github.com/harmony-one/ethhmy-bridge.testsโ€‹