Skip to content

Conversion BTC to SBTC and vice versa

Meri Herrera edited this page May 3, 2018 · 7 revisions

Summary

This document describes the 2-way peg mechanism. This is for converting BTC to SBTC to use within the RSK Blockchain and for transfering your SBTC balance back to the BTC network.

Requirements

  • You need to be in full control of your private key
  • You need a BTC Wallet properly configured using the previously mentioned private key
  • You need a RSK node up and running, with the RPC interface enabled with the personal and eth modules enabled (how do I run a RSK Node?)
  • You need to be whitelisted in the RSK network (what's to be whitelisted?)

Sending money from BTC to SBTC

  1. Send a BTC transaction to the Federation Address (check Notes #1)
  2. Obtain the BTC transaction hash ID
  3. Open your preferred BTC block explorer (i.e. Blocktrail)
  4. Search for your BTC transaction (check Notes #2)
  5. You have to wait a minimum of 100 confirmations plus a minimum of 5 minutes for checking your SBTC balance

Checking your SBTC balance

  1. Convert the private key to RSK format using https://utils.rsk.co (this can be run offline), write down your RSK address
  2. Execute this command (check Notes #3)
  $ curl -X POST --data '{"method":"eth_getBalance", "params":["<RSKAddress>"], "jsonrpc":"2.0", "id":1}' http://<RSKNode>:<RSKNodePort>

Returning your balance from SBTC to BTC

  1. Convert the private key to RSK format using https://utils.rsk.co (this can be run offline), you'll obtain a derived RSK private key and your RSK address
  2. Add your obtained RSK private key to your RSK node:
  $ curl -X POST --data '{"method":"personal_importRawKey", "params":["<RSKConvertedPrivateKey>", "<passPhraseToEncryptPrivKey>"], "jsonrpc":"2.0", "id":1}' http://<RSKNode>:<RSKNodePort>
  1. Unlock your account for transfers:
  $ curl -X POST --data '{"method":"personal_unlockAccount", "params":["<RSKAddress>", "<passPhraseJustUsedToEncryptPrivKey>", ""], "jsonrpc":"2.0", "id":1}' http://<RSKNode>:<RSKNodePort>
  1. Transfer your desired amount
  $ curl -X POST --data '{"method":"eth_sendTransaction", "params":[{"from": "<RSKAddress>", "to": "0x0000000000000000000000000000000001000006", "gasPrice": 183000000, "gas": 100000, "value": <valueToReleaseInWeis>}], "jsonrpc":"2.0", "id":1}' http://<RSKNode>:<RSKNodePort>
  1. Wait 4000 RSK confirmations and then wait at least 10 more minutes for your funds to arrive to your BTC address.

Notes

#1. You can get the Federation Address (for both: testnet and mainnet) invoking getFederationAddress method of the bridge contract with this information:

Contract Address: 0x0000000000000000000000000000000001000006

Contract ABI:

[{ "name": "getFederationAddress", "type": "function", "constant": true, "inputs": [], "outputs": [{ "name": "", "type": "string" }] }]

#2. Check that the first input should spend a P2PKH (pay to public key hash) output.

#3. Rsk addresses must start with 0x

Clone this wiki locally