waves-repl
Javascript console to interact with waves blockchain. React component
Last updated 9 months ago by siemarell .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install waves-repl 
SYNC missed versions from official npm registry.

REPL

About

This repository contains javascript console for waves blockchain. It is built on top of jsconsole and have predefined functions to work with waves

Builtin functions

JS lib

Console uses waves-transactions library. Top level library functions are bound to console global scope. The difference is that in console, seed argument is equal to env.SEED by default. You need to pass null explicitly if you only want to create transaction and not to sign it E.x.:

Console
const signedTx = transfer({amount: 100, recipient: '3MyAGEBuZGDKZDzYn6sbh2noqk9uYHy4kjw', senderPublicKey: '8ViwGfvyyN1teUKV4Uvk2orK6XiYB4S4VuM2DqJ9Mj5b'}, null)

//returns tx with no proofs
{
  "type": 4,
  "version": 2,
  "fee": 100000,
  "senderPublicKey": "8ViwGfvyyN1teUKV4Uvk2orK6XiYB4S4VuM2DqJ9Mj5b",
  "timestamp": 1542640481876,
  "proofs": [],
  "id": "CveeKH16XQcshV5GZP2RXppg3snxcKqRsM4wE5gxcuzc",
  "chainId": "T",
  "amount": 100,
  "recipient": "3MyAGEBuZGDKZDzYn6sbh2noqk9uYHy4kjw"
}

Additional functions

Broadcast signed tx using node from global variable

const resp = await broadcast(signedTx)

Deploy current open contract using node from global variable

const resp = deploy()

Sign arbitrary transaction

const tx = transfer({amount: 100, recipient: '3MyAGEBuZGDKZDzYn6sbh2noqk9uYHy4kjw', senderPublicKey: '8ViwGfvyyN1teUKV4Uvk2orK6XiYB4S4VuM2DqJ9Mj5b'}, null)
const signedTx = signTx(tx)

Compile contract. Returns base64

const compiled = compile(contractText)

Get contract text by tab name. Used inside web-ide or vscode plugin

const contractText = file(tabName)

Get contract text from currently open tab. Used inside web-ide or vscode plugin

const contractText = contract()

Keys

address(seed = env.SEED) // Address from seed. 
keyPair(seed = env.SEED) // Keypair from seed
publicKey(seed = env.SEED) // Public key from seed
privateKey(seed = env.SEED) // Private key from seed

Global object env

env.SEED // Default seed
env.CHAIN_ID // Default network byte
env.API_BASE // Node url 
env.editors // Open editor tabs info

Usage

Dev server:

npm start

Starts dev server

React component

import * as React from 'react';
import {render} from 'react-dom';
import {Repl} from 'waves-repl';

class App extends React.Component {
    public consoleRef = React.createRef<Repl>();

    componentDidMount(){
        // Get console instance
        const console = this.consoleRef.current!;
        
        // Access to console api
        (global as any)['updateEnv'] = console.updateEnv;
        (global as any)['API'] = console.API;
        (global as any)['methods'] = console.methods;

        (global as any)['updateEnv']({
            SEED: 'abracadabra',
            API_BASE: 'https://testnodes.wavesnodes.com',
            CHAIN_ID: 'T',
            file: () => 'Placeholder file content'
        });

    }
    render(){
        return <Repl theme="dark" ref={this.consoleRef}/>
    }
}
render(<App/>, document.getElementById('root'));

Current Tags

  • 2.0.0                                ...           latest (9 months ago)

52 Versions

  • 2.0.0                                ...           9 months ago
  • 1.5.1                                ...           9 months ago
  • 1.5.0                                ...           9 months ago
  • 1.4.13                                ...           9 months ago
  • 1.4.12                                ...           10 months ago
  • 1.4.11                                ...           10 months ago
  • 1.4.10                                ...           10 months ago
  • 1.4.9                                ...           a year ago
  • 1.4.8                                ...           a year ago
  • 1.4.7                                ...           a year ago
  • 1.4.6                                ...           a year ago
  • 1.4.5                                ...           a year ago
  • 1.4.4                                ...           a year ago
  • 1.4.3                                ...           a year ago
  • 1.4.2                                ...           a year ago
  • 1.4.1                                ...           a year ago
  • 1.4.0                                ...           a year ago
  • 1.3.3                                ...           a year ago
  • 1.3.2                                ...           a year ago
  • 1.3.1                                ...           a year ago
  • 1.3.0                                ...           a year ago
  • 1.2.1                                ...           a year ago
  • 1.2.0                                ...           a year ago
  • 1.1.8                                ...           a year ago
  • 1.1.7                                ...           a year ago
  • 1.1.6                                ...           a year ago
  • 1.1.5                                ...           a year ago
  • 1.1.4                                ...           a year ago
  • 1.1.3                                ...           a year ago
  • 1.1.2                                ...           a year ago
  • 1.1.1                                ...           a year ago
  • 1.1.0                                ...           a year ago
  • 1.0.12                                ...           a year ago
  • 0.1.7                                ...           a year ago
  • 0.1.6                                ...           a year ago
  • 0.1.5                                ...           a year ago
  • 0.1.4                                ...           a year ago
  • 0.1.3                                ...           a year ago
  • 0.1.2                                ...           a year ago
  • 0.1.1                                ...           a year ago
  • 0.1.0                                ...           a year ago
  • 1.0.11                                ...           a year ago
  • 1.0.10                                ...           a year ago
  • 1.0.9                                ...           a year ago
  • 1.0.8                                ...           a year ago
  • 1.0.7                                ...           a year ago
  • 1.0.6                                ...           a year ago
  • 1.0.5                                ...           a year ago
  • 1.0.4                                ...           a year ago
  • 1.0.3                                ...           a year ago
  • 1.0.1                                ...           a year ago
  • 1.0.0                                ...           a year ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 53
Dependencies (9)
Dev Dependencies (28)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |