forked from rsksmart/rskj
-
Notifications
You must be signed in to change notification settings - Fork 0
Conversion BTC to SBTC and vice versa
Meri Herrera edited this page May 3, 2018
·
7 revisions
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.
- 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?)
- Send a BTC transaction to the Federation Address (check Notes #1)
- Obtain the BTC transaction hash ID
- Open your preferred BTC block explorer (i.e. Blocktrail)
- Search for your BTC transaction (check Notes #2)
- You have to wait a minimum of 100 confirmations plus a minimum of 5 minutes for checking your SBTC balance
- Convert the private key to RSK format using https://utils.rsk.co (this can be run offline), write down your RSK address
- Execute this command (check Notes #3)
$ curl -X POST --data '{"method":"eth_getBalance", "params":["<RSKAddress>"], "jsonrpc":"2.0", "id":1}' http://<RSKNode>:<RSKNodePort>
- 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
- 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>
- Unlock your account for transfers:
$ curl -X POST --data '{"method":"personal_unlockAccount", "params":["<RSKAddress>", "<passPhraseJustUsedToEncryptPrivKey>", ""], "jsonrpc":"2.0", "id":1}' http://<RSKNode>:<RSKNodePort>
- 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>
- Wait 4000 RSK confirmations and then wait at least 10 more minutes for your funds to arrive to your BTC address.
#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