Aureum is a Layer 2 solution for Ethereum. Plasma consists of three major parts:
- Plasma chain: A simple proof-of-authority chain where the actual transactions take place.
- Plasma contract: A smart contract deployed on root chain which handles the deposits and withdrawals for the child chain (plasma chain).
- Ethereum blockchain: The root chain which only records the block headers of the plasma chain.
The complete cycle of interacting with plasma is made up of three stages.
Participants deposit to the plasma contract on the root chain. Then the operator at the plasma chain will construct a deposit transaction according to the contract event when building a new block.
Participants could transact with each other on the plasma chain without notifying the root chain. Only when every block is created by the operator, it will submit the block header to the plasma contract on the root chain.
A withdrawal is initiated by calling the plasma contract. After creating a withdrawal, user needs to wait 7 days for other participants to challenge it. If anyone could prove the given withdrawal that has been spent later on the plasma chain, the withdrawal will be canceled. Otherwise, after 7 days and without any other withdrawals with higher priority, user could withdraw his funds back to the root chain.
npm i
npm run bootstrap
npm link
Start a local root chain:
npm run chain
Compile and deploy the plasma manager contract:
npm run migrate
The contract artifacts, operator address and contract addresses will be exported to the plasma package automatically. Start the plasma chain with:
npm run plasma
Get the whole blockchain.
None
curl http://localhost:3001/blocks
Miner mines a new block.
None
curl -X POST http://localhost:3001/mineBlock
You must first deplosit ETH into the PlasmaChainManager Contract on the root chain. In a new terminal:
npm run console
Next, deposit ETH to the PlasmaChainManager contract:
(development)> var plasma = new PlasmaChainManager(PlasmaChainManager.address)
(development)> var accounts = await web3.eth.getAccounts()
(development)> plasma.deposit({ from: accounts[0], value: web3.utils.toWei('1', 'ether'), gas: 300000 })
The following is a simplifed API that allows for the movement of ETH around on the Plasma chain.
Create a transaction to other participants. User could specify at most two UTXOs to spend. Also note that the units used in field amount
is ether.
Name | Type | Required | Description |
---|---|---|---|
from | Address | Yes | Transfer funds from whom |
to | Address | Yes | Transfer funds to whom |
amount | Decimal | Yes | How much ether (in ether) |
curl -H "Content-type:application/json" --data '{"from": "0x627306090abaB3A6e1400e9345bC60c78a8BEf57", "to": "0x3B0bA3134Ac12Cc065d4dBa498a60cba5Ef16098", "amount": 2}' http://localhost:3001/transact
Deposit funds to Plasma smart contract.
Name | Type | Required | Description |
---|---|---|---|
address | Address | Yes | Deposit from whom |
amount | Integer | Yes | How much funds to deposit |
curl -H "Content-type:application/json" --data '{"address": "0x627306090abaB3A6e1400e9345bC60c78a8BEf57", "amount": 1}' http://localhost:3001/deposit
Create a new withdrawal.
Name | Type | Required | Description |
---|---|---|---|
blkNum | Integer | Yes | The position of the UTXO user wants to withdraw |
txIndex | Integer | Yes | The position of the UTXO user wants to withdraw |
oIndex | Integer | Yes | The position of the UTXO user wants to withdraw |
from | Address | Yes | The owner of the UTXO |
curl -H "Content-type:application/json" --data '{"blkNum": 3, "txIndex": 1, "oIndex": 0, "from": "0x627306090abaB3A6e1400e9345bC60c78a8BEf57"}' http://localhost:3001/withdraw/create
Create a withdrawal challenge.
Name | Type | Required | Description |
---|---|---|---|
withdrawalId | Integer | Yes | The withdrawal ID user wants to challenge |
blkNum | Integer | Yes | The position of the UTXO user wants to challenge |
txIndex | Integer | Yes | The position of the UTXO user wants to challenge |
oIndex | Integer | Yes | The position of the UTXO user wants to challenge |
from | Address | Yes | The owner of the UTXO |
curl -H "Content-type:application/json" --data '{"withdrawalId": 4000000000, "blkNum": 4, "txIndex": 2, "oIndex": 1, "from": "0x857470E5FBa91EE27fa1B84F838ae8220ac91aB8"}' http://localhost:3001/withdraw/challenge
Finalize withdrawals manually.
Name | Type | Required | Description |
---|---|---|---|
from | Address | Yes | Who initiates the withdrawal finalization |
curl -H "Content-type:application/json" --data '{"from": "0x627306090abaB3A6e1400e9345bC60c78a8BEf57"}' http://localhost:3001/withdraw/finalize