First, install the Node module via NPM or yarn:
npm install --save kyokan-plasma-client# oryarn add kyokan-plasma client
Since the client is written in Typescript, type definitions are included inside the package itself.
You'll need the following things to use Plasma:
Web3instance that supports signing, either through a custom
Web3provider or by pointing to an Ethereum node with unlocked accounts.
- The hostname and port of a running
- The address of the Plasma smart contract.
- Your private key.
Once you have those things, create an instance of the
Plasma class like this:
;const web3 = '...';const client =web3: web3contractAddress: '0x123abc'rootUrl: 'localhost:6545'privateKey: '0x12345';
To deposit funds, use the
// all values are in Weiconst depositReceipt = await client;
To spend that deposit, pass in the
depositNonce included in the receipt to
const tx = await client;
To send funds once you've spent your deposits, simply call
send without a
depositNonce. The client will pick the correct UTXOs and spend them for you.