Welcome to web3-fusion-extend’s documentation!

Fusion is an enterprise financial infrastructure blockchain solution simplifying the full digital life of any asset.

With the ethreum world users are familiar that they have a wallet and a balance. If user own ERC20 or ERC721 tokens wallets applications hide the technicalities of calling contracts to get their values.

Fusion evolutionary approach moves the asset and its balance to the users ethereum wallet.

No contracts are needed as multiple balances each with a unique asset Id can be contained on the chain in the wallet.

Other inflationary practices to code such as creating escrows and atomic swaps are also eliminated by simply having the asset in the users account.

Fusion allows all assets to have time periods, these time periods enable safe lending of an asset.

So a balance of 1 Fusion Token can be Timelocked for 30 days, sent to another account.

At the end of the 30 days that other account no longer can access that value in their wallet.

All done natively on the chain without contracts.

The goal of Fusion is to:

  • make assets (tokens) a natural part of send and receive of value
    • eliminate need for ERC20 contracts
    • eliminate need for ERC721 contracts
    • simply the familiar paridigm of from, to, value -> from, to, assetId, value
  • introduce the concept of timelock of an asset as a natural wallet feature
    • split the use of any asset into any sliver of time
    • allow that time portion of that asset to be securely lent to someone
  • quantum swap - introduce a one transaction method to exchange assets between parties
    • the ability to exchange assets between accounts in one transaction on the blockchain without chance of error
    • assets that are timelocked can be exchanged
    • swaps can be made public to all users or a targeted user.

The purpose of the web3-fusion-extend libary is to take the popular web3.js package and open it up to the extended functionallity of that the Fusion blockchain server provides.

Contents:

Keyword Index, Search Page

Note

This documentation is work in progress and web3-fusion-extend 1.0 stable is not yet released! You can find the current documentation for web3-fusion-extend 0.x.x at.

Contributing

If you’re reading this, you’re awesome! Thank you for helping us make this project great and being a part of the web3-fusion-extend community. Here are a few guidelines that will help you along the way.

Submitting a pull request

web3-fusion-extend is a community project, so pull requests are always welcome, but, before working on a large change, it is best to open an issue first to discuss it with the maintainers.

When in doubt, keep your pull requests small. To give a PR the best chance of getting accepted, don’t bundle more than one feature or bug fix per pull request. It’s always best to create two smaller PRs than one big one.

As with issues, please make sure your title clear explains the issue.

When adding new features or modifying existing, please attempt to include tests to confirm the new behaviour. You can read more about our test setup here.

Branch Structure

All stable releases are tagged (view tags). At any given time, master represents the latest development version of the library. Patches or hotfix releases are prepared on an independent branch.

master is unsafe

We will do our best to keep master in good shape, with tests passing at all times. However, in order to move fast, we will make API changes that your application might not be compatible with.

How to increase the chance of being accepted?

We will only accept a pull request for which all tests pass. Make sure the following is true:

  • The branch is not behind master.
  • If a feature is being added:
    • If the result was already achievable with the core library, explain why this feature needs to be added to the core.
    • It includes relevant tests.
    • If this is a common use case, considered adding an example to the documentation.
  • If a bug is being fixed, test cases that fail without the fix are included.
  • The code is formatted (run yarn prettier).
  • The code is linted (run yarn lint).
  • If API documentation is being changed in the source, yarn docs:api was run.
  • If prop types were changed, the TypeScript declarations were updated.
  • If TypeScript declarations were changed, yarn typescript passed.
  • The PR title follows the pattern [Component] Imperative commit message. (See: (How to Write a Git Commit Message) for a great explanation)

Getting started

Please create a new branch from an up to date master on your fork. (Note, urgent hotfixes should be branched off the latest stable release rather than master)

  1. Fork the web3-fusion-extend repository on Github
  2. Clone your fork to your local machine git clone git@github.com:<yourname>/web3-fusion-extend.git
  3. Create a branch git checkout -b my-topic-branch
  4. Make your changes, lint, then push to to GitHub with git push --set-upstream origin my-topic-branch.
  5. Visit GitHub and make your pull request.

If you have an existing local repository, please update it before you start, to minimise the chance of merge conflicts.

git remote add upstream git@github.com:FusionFoundation/web3-fusion-extend.git
git checkout master
git pull upstream master
git checkout -b my-topic-branch
yarn

Coding style

Please follow the coding style of the project. web3-fusion-extend uses eslint, so if possible, enable linting in your editor to get real-time feedback. The linting rules can be run manually with the following command yarn lint.

You can also run yarn prettier to reformat the code.

Finally, when you submit a pull request, they are run again by Circle CI, but hopefully by then your code is already clean!

License

By contributing your code to the FusionFoundation/web3-fusion-extend GitHub repository, you agree to license your contribution under the MIT license.

Note

This documentation is work in progress and web3-fusion-extend 1.0 stable is not yet released! You can find the current documentation for web3-fusion-extend 0.x.x at.

Getting Started

web3-fusion-extend is a collection of libraries which allow you to interact with a local or remote fusion node, using a HTTP or IPC connection.

Fusion offers a radical approach to representing value within a block chain environment.

A public address contain multiple assets and balances for these assets.

An assetId is the id returned when an asset is created and actions can be performed on it.

The asset creator also has the ability to increase and decrease supply.

This enables cross chain and cross functional systems to be built that enable the interchange of assets.

Assets can also be TimeLocked. When an asset is time locked its ownership is leant for the period specified. At the end of time lock period the rights of the asset are returned to the original owner.

With the representation of assets, the need to exchange assets securely and simply becomes paramount.

The Fusion protocol introduces quantumSwaps which are composed of three functions:
makeSwap - tell others what you will exchange for your asset recallSwap - cancel the request for an exchange takeSwap - exchange your asset for the other parties asset listed in the make swap

This package extends the Ethereum compatible JavaScript API which implements the Generic JSON RPC spec to support the Fusion protocol.

It’s available on npm as a node module.

https://badge.fury.io/js/web3-fusion-extend.svg

You need to run a local Ethereum node to use this library.

Installation

Node.js

npm install web3-fusion-extend

Yarn

yarn add web3-fusion-extend

Usage

Create a web3 object as your normally would and then call web3FusionExtend with that object. web3 will then have two additional interfaces (fsn and fsntx)

var web3FusionExtend = require('web3-fusion-extend')
web3 = new Web3(provider);
web3 = web3FusionExtend.extend(web3)
console.log(web3.fsn.consts.FSNToken);
console.log(web3); // {fsn: .., fsntx: ...} // It's here!

There you go, now you can use it:

var balance = web3.eth.getBalance(coinbase);
web3.fsn
    .getAllBalances( web3.eth.coinbase ) // fsn supports multiple assets and balances on an address
    .then( balances => {
      console.log( balances )
      assert(  balances[web3.fsn.consts.FSNToken] , "there should be a balance for fusion tokens always"  )
      done();
    })
    .catch(err => {
      done(err);
    });

You can find more examples in the test directory.

There is also a full block explorer api written as an example.

Contribute!

We’d greatly appreciate any contribution you make.

Requirements

Node.js npm

# On Linux:
sudo apt-get update
sudo apt-get install nodejs
sudo apt-get install npm
sudo apt-get install nodejs-legacy

Testing (mocha)

When testing a connect string to a local fusion node and a wallet address is needed as environment variables

CONNECT_STRING="ws://3.16.110.25:9001" WALLET_ADDRESS="0x4A5a7Aa4130e407d3708dE56db9000F059200C62" npm test

Community

Documentation

Documentation

License

LGPL-3.0+ © 2015 Contributors

autoPurchaseTickets

Ticket purchase applicaton

An application to keep tickets at a constant level built with the web3-fusion-extend package

Example

node autoPurchaseTicket --c "wss://example.com" -p "./password.txt" -k "./keystore.key" -n 10
-c --connectString web socket gateway to connect to
-k  --keyStore keystore file to use
-p  --passPharseFile key file
-g  -- gasPrice gas price 1 - 100 (defaults to 2 gwei)
-n  --Number of tickets to purchase

blockexplorerapi

Overview

This block explorer api section shows how to collect all information from the fusion block chain and update a mysql database.

You will need a node for the application readAllBlocksToDatabase.js to communicate with as well as a mysql database to store the information.

You will need an environment string called DB_CONNECT_STRING

It can be passed on the command line.

DB_CONNECT_STRING="{'host':'mysqlserver,'user':'adminuser','password':'password','database':'fusionblockdb','connectionLimit':100}" node readAllBlocksToDatabase.js

You can then host the api server for the database via:

DB_CONNECT_STRING="{'host':'mysqlserver,'user':'adminuser','password':'password','database':'fusionblockdb','connectionLimit':100}" nodemon   node ./bin/www

Fusion Org and its public explorer api

Fusion organization keeps an api endpoint open at https://api.fusionnetwork.io to assist in application development

You can try commands like https://api.fusionnetwork.io/blocks/latest or https://api.fusionnetwork.io/transactions/latest

Note if you are not a developer the results may look scary but they are the actual last block or transaction info

Installation

npm install

API Commands

If running locally replace api.fusionnetwork.io with your own server link

FSNConstants

Constants

web3.fsn.consts = {}

FSNToken

FSNToken: "0xffffffffffffffffffffffffffffffffffffffff"

TicketLogAddress

TicketLogAddress: "0xfffffffffffffffffffffffffffffffffffffffe",

TicketLogAddress_Topic_To_Function

TicketLogAddress_Topic_To_Function: {
  0: "ticketSelected",
  1: "ticketReturn",
  2: "ticketExpired"
},

TicketLogAddress_Topic_ticketSelected

TicketLogAddress_Topic_ticketSelected:
  "0x0000000000000000000000000000000000000000000000000000000000000000",

TicketLogAddress_Topic_ticketReturn

TicketLogAddress_Topic_ticketReturn:
  "0x0000000000000000000000000000000000000000000000000000000000000001",

TicketLogAddress_Topic_ticketExpired

TicketLogAddress_Topic_ticketExpired:
  "0x0000000000000000000000000000000000000000000000000000000000000002",

FSNCallAddress

FSNCallAddress: "0xffffffffffffffffffffffffffffffffffffffff",

FSNCallAddress_Topic_To_Function

FSNCallAddress_Topic_To_Function: {
  // GenNotationFunc wacom
  0: "GenNotationFunc", // = iota
  // GenAssetFunc wacom
  1: "GenAssetFunc",
  // SendAssetFunc wacom
  2: "SendAssetFunc",
  // TimeLockFunc wacom
  3: "TimeLockFunc",
  // BuyTicketFunc wacom
  4: "BuyTicketFunc",
  // AssetValueChangeFunc wacom
  5: "AssetValueChangeFunc",
  // MakeSwapFunc wacom
  6: "MakeSwapFunc",
  // RecallSwapFunc wacom
  7: "RecallSwapFunc",
  // TakeSwapFunc wacom
  8: "TakeSwapFunc"
        // MakeSwapFuncExt wacom
    9: "MakeSwapFuncExtOld",
    // MakeSwapFuncExt wacom
    10: "MakeSwapFuncExt",
    // TakeSwapFuncExt wacom
    11: "TakeSwapFuncExt",
    // AssetValueChangeFunc wacom
    12: "AssetValueChangeExtFunc"
},

FSNCallAddress_Topic_GenNotationFunc

FSNCallAddress_Topic_GenNotationFunc:
  "0x0000000000000000000000000000000000000000000000000000000000000000",

FSNCallAddress_Topic_GenAssetFunc

FSNCallAddress_Topic_GenAssetFunc:
  "0x0000000000000000000000000000000000000000000000000000000000000001",

FSNCallAddress_Topic_SendAssetFunc

FSNCallAddress_Topic_SendAssetFunc:
  "0x0000000000000000000000000000000000000000000000000000000000000002",

FSNCallAddress_Topic_TimeLockFunc

FSNCallAddress_Topic_TimeLockFunc:
  "0x0000000000000000000000000000000000000000000000000000000000000003",

FSNCallAddress_Topic_BuyTicketFunc

FSNCallAddress_Topic_BuyTicketFunc:
  "0x0000000000000000000000000000000000000000000000000000000000000004",

FSNCallAddress_Topic_AssetValueChangeFunc

FSNCallAddress_Topic_AssetValueChangeFunc:
  "0x0000000000000000000000000000000000000000000000000000000000000005",

FSNCallAddress_Topic_MakeSwapFunc

FSNCallAddress_Topic_MakeSwapFunc:
  "0x0000000000000000000000000000000000000000000000000000000000000006",

FSNCallAddress_Topic_RecallSwapFunc

FSNCallAddress_Topic_RecallSwapFunc:
  "0x0000000000000000000000000000000000000000000000000000000000000007",

FSNCallAddress_Topic_TakeSwapFunc

FSNCallAddress_Topic_TakeSwapFunc:
  "0x0000000000000000000000000000000000000000000000000000000000000008"

FSNCallAddress_Topic_MakeSwapFuncExtOld:
“0x0000000000000000000000000000000000000000000000000000000000000009”,
FSNCallAddress_Topic_MakeSwapFuncExt:
“0x000000000000000000000000000000000000000000000000000000000000000a”,
FSNCallAddress_Topic_TakeSwapFuncExt:
“0x000000000000000000000000000000000000000000000000000000000000000b”,
FSNCallAddress_Topic_AssetValueChangeExtFunc:
“0x000000000000000000000000000000000000000000000000000000000000000c”

Note

This documentation is work in progress and web3-fusion-extend 1.0 stable is not yet released! You can find the current documentation for web3-fusion-extend 0.x.x at.

fsn

FSN documentation

fsn.assetToTimeLock({asset:"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",from:fsn.coinbase,to:"0x2b1a3eca81ba03a9a4c95f4a04679c90838d7165",start:"0x100",end:"0x200",value:"0x100"},"123456")
fsn.assetToTimeLock({asset:"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",from:fsn.coinbase,to:"0x4A5a7Aa4130e407d3708dE56db9000F059200C62",start:"0x100",end:"0x200",value:"0x100"},"123456")

common params CP from send from or call member gas gas limit gasPrice gas price nonce send from or call member account nonce

common send params CSP CP asset the asset ID to receiver value amount

allAssets

fsn.allAssets()
...

allAssets get the all assets list no params

Parameters

none

Returns

Asset Object: With the following methods:

  • ID        Hash: Description
  • Owner     Address: Description
  • Name      string: Description
  • Symbol    string: Description
  • Decimals  uint8: Description
  • Total     *big.Int `json:",string"`: Description
  • CanChange bool: Description

Example

fsn.allAssets()

allNotation

fsn.allNotation()
...

allNotation get the all notation no params

Parameters

none

Returns

Object: With the following methods:

  • Object: Description

Example

fsn.allNotation()

allSwaps

fsn.allSwaps()
...

allSwaps get the all quantum swap list no params

Parameters

none

Returns

Object: With the following methods:

  • Object: Description

Example

fsn.allSwaps()

allTickets

fsn.allTickets()
...

allTickets get the all notation no params

Parameters

none

Returns

Object: With the following methods:

  • Object: Description

Example

fsn.allTickets()

allTicketsByAddress

fsn.allTicketsByAddress(eth.coinbase)
...

allTicketsByAddress get all tickets by address address the user’s address

Parameters

none

Returns

Object: With the following methods:

  • Object: Description

Example

fsn.allTicketsByAddress(eth.coinbase)

totalNumberOfTickets

fsn.totalNumberOfTickets()
...

totalNumberOfTickets return number of active tickets no params

Parameters

none

Returns

Object: With the following methods:

  • Object: Description

Example

fsn.totalNumberOfTickets()

totalNumberOfTicketsByAddress

fsn.totalNumberOfTicketsByAddress(eth.coinbase)
...

totalNumberOfTicketsByAddress return number of tickets an address controls address address that bought tickets

Parameters

none

Returns

Object: With the following methods:

  • Object: Description

Example

fsn.totalNumberOfTicketsByAddress(eth.coinbase)

assetToTimeLock

fsn.assetToTimeLock({asset:"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",from:fsn.coinbase,to:"0xa7455DF112c953F3c73c2C25559965e1A8a20024",start:"0x1",end:"0x2A300",value:"0x1400000000000000"},"123456")
...

assetToTimeLock send the asset to time lock CSP see the top startTime the start time of the time lock endTime the end time of the time lock password the account password

Parameters

none

Returns

Object: With the following methods:

  • Object: Description

Example

fsn.assetToTimeLock({asset:"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",from:fsn.coinbase,to:"0xa7455DF112c953F3c73c2C25559965e1A8a20024",start:"0x1",end:"0x2A300",value:"0x1400000000000000"},"123456")

fsn.assetToTimeLock({asset:"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",from:fsn.coinbase,to:"0xa7455DF112c953F3c73c2C25559965e1A8a20024",start:"0x2a900",end:"0x3A300",value:"0x1400000000000000"},"123456")

fsn.assetToTimeLock({asset:"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",from:fsn.coinbase,to:"0xa7455DF112c953F3c73c2C25559965e1A8a20024",start: getHexDate('2018-12-01') ,end: getHexDate('2019-01-01'),value:"0x1340000000000000"},"123456")

getHexDate

fsn.getHexDate('2018-12-01')
...

getHexDate helper function to convert date to posix time in hex

Parameters

none

Returns

Object: With the following methods:

  • Object: Description

Example

fsn.getHexDate('2018-12-01')
fsn.assetToTimeLock({asset:"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",from:fsn.coinbase,to:fsn.coinbase,start:"0x1",end:"0x100000",value:"0x100"},"123456")

timeLockToAsset

fsn.timeLockToAsset({asset:"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",from:fsn.coinbase,to:fsn.coinbase,start:"0x0",end:"0x0",value:"0x100"},"123456")
...

timeLockToAsset send the time lock to asset CSP see the top startTime the start time of the time lock endTime the end time of the time lock password the account password

Parameters

none

Returns

Object: With the following methods:

  • Object: Description

Example

fsn.timeLockToAsset({asset:"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",from:fsn.coinbase,to:fsn.coinbase,start:"0x0",end:"0x0",value:"0x100"},"123456")

timeLockToTimeLock

fsn.timeLockToTimeLock({asset:"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",from:fsn.coinbase,to:"0x2b1a3eca81ba03a9a4c95f4a04679c90838d7165",start:"0x101",end:"0x200",value:"0x100"},"123456")
...

timeLockToTimeLock send the time lock CSP see the top startTime the start time of the time lock endTime the end time of the time lock password the account password

Parameters

none

Returns

Object: With the following methods:

  • Object: Description

Example

fsn.timeLockToTimeLock({asset:"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",from:fsn.coinbase,to:"0x2b1a3eca81ba03a9a4c95f4a04679c90838d7165",start:"0x101",end:"0x200",value:"0x100"},"123456")

buyTicket

fsn.buyTicket({from:fsn.coinbase},"123456")
...

buyTicket buy the ticket CP see the top and the “from” ignore from who buy the ticket password the account password

Parameters

none

Returns

Object: With the following methods:

  • Object: Description

Example

fsn.buyTicket({from:fsn.coinbase},"123456")

genAsset

fsn.genAsset({from:fsn.coinbase,name:"FusionTest",symbol:"FST",decimals:1,total:"0x200"},"123456")
fsn.genAsset({from:"0x91db50f5c36ae7616009d4e94462dca4d4c7e833",name:"JONESY",symbol:"JSY",decimals:1,total:"0x2000000000"},"123123123")
...

genAsset generate a asset CP see the top and the “from” ignore from who gen the asset and the owner of the asset name the name of asset symbol the symbol of asset decimals the asset decimal digit total the total number of the asset and the owner will be get same number asset CanChange whether asset can be incremented or decremented by the owner [optional] password the account password

Parameters

none

Returns

Object: With the following methods:

  • Object: Description

Example

fsn.genAsset({from:fsn.coinbase,name:"FusionTest",symbol:"FST",decimals:1,total:"0x200"},"123456")
fsn.genAsset({from:"0x91db50f5c36ae7616009d4e94462dca4d4c7e833",name:"JONESY",symbol:"JSY",decimals:1,total:"0x2000000000"},"123123123")

genNotation

fsn.genNotation({from:fsn.coinbase},"123456")
...

genNotation gen a notation for a account CP see the top and the “from” ignore from who gen the notation password the account password

Parameters

none

Returns

Object: With the following methods:

  • Object: Description

Example

fsn.genNotation({from:fsn.coinbase},"123456")

sendAsset

fsn.sendAsset({from:fsn.coinbase,to:"0x2b1a3eca81ba03a9a4c95f4a04679c90838d7165",value:"0x1",asset:"0x514a46f34e6eb0a98abb3595c4aec33ca8ddf69f135c8fed89e78d0808047965"},"123456")

fsn.sendAsset({from:fsn.coinbase,to:"0x91db50F5c36aE7616009d4e94462DcA4D4c7e833",value:"0x2",asset:"0x88d18f81620e5684e880dddcf0b6c167a9154d4c499bc9fad47b98634110eeec"},"123456")
...

sendAsset send asset to other account CSP see the top

Parameters

none

Returns

Object: With the following methods:

  • Object: Description

Example

fsn.sendAsset({from:fsn.coinbase,to:"0x2b1a3eca81ba03a9a4c95f4a04679c90838d7165",value:"0x1",asset:"0x514a46f34e6eb0a98abb3595c4aec33ca8ddf69f135c8fed89e78d0808047965"},"123456")

fsn.sendAsset({from:fsn.coinbase,to:"0x91db50F5c36aE7616009d4e94462DcA4D4c7e833",value:"0x2",asset:"0x88d18f81620e5684e880dddcf0b6c167a9154d4c499bc9fad47b98634110eeec"},"123456")

decAsset

fsn.decAsset({from:fsn.coinbase,to:"0x2b1a3eca81ba03a9a4c95f4a04679c90838d7165",value:"0x1",asset:"0x514a46f34e6eb0a98abb3595c4aec33ca8ddf69f135c8fed89e78d0808047965"},"123456")
...

decAsset decrease account asset balance CSP see the top and the “from”,”to” ignore from the asset owner to the dec account password the account password

Parameters

none

Returns

Object: With the following methods:

  • Object: Description

Example

fsn.decAsset({from:fsn.coinbase,to:"0x2b1a3eca81ba03a9a4c95f4a04679c90838d7165",value:"0x1",asset:"0x514a46f34e6eb0a98abb3595c4aec33ca8ddf69f135c8fed89e78d0808047965"},"123456")

incAsset

fsn.incAsset({from:fsn.coinbase,to:"0x2b1a3eca81ba03a9a4c95f4a04679c90838d7165",value:"0x1",asset:"0x514a46f34e6eb0a98abb3595c4aec33ca8ddf69f135c8fed89e78d0808047965"},"123456")
...

incAsset increase account asset balance CSP see the top and the “from”,”to” ignore from the asset owner to the inc account password the account password

Parameters

none

Returns

Object: With the following methods:

  • Object: Description

Example

fsn.incAsset({from:fsn.coinbase,to:"0x2b1a3eca81ba03a9a4c95f4a04679c90838d7165",value:"0x1",asset:"0x514a46f34e6eb0a98abb3595c4aec33ca8ddf69f135c8fed89e78d0808047965"},"123456")

getAddressByNotation

fsn.getAddressByNotation(104)
...

getAddressByNotation get the notation of the address notation account notation

Parameters

none

Returns

Object: With the following methods:

  • Object: Description

Example

fsn.getAddressByNotation(104)

getAllBalances

fsn.getAllBalances("0x9c48c796cb0bed51a14291bc8cc56dab5aed7b5c")
...

getAllBalances get all assets balances address the user’s address blockNumber default now block number

Parameters

none

Returns

Object: With the following methods:

  • Object: Description

Example

fsn.getAllBalances("0x9c48c796cb0bed51a14291bc8cc56dab5aed7b5c")

getAllTimeLockBalances

fsn.getAllTimeLockBalances("0x9c48c796cb0bed51a14291bc8cc56dab5aed7b5c")
...

getAllTimeLockBalances get all time lock balances address the user’s address blockNumber default now block number

Parameters

none

Returns

Object: With the following methods:

  • Object: Description

Example

fsn.getAllTimeLockBalances("0x9c48c796cb0bed51a14291bc8cc56dab5aed7b5c")

getAsset

fsn.getAsset("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")
...

getAsset get the asset info assetID the asset ID

Parameters

none

Returns

Object: With the following methods:

  • Object: Description

Example

fsn.getAsset("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")

getBalance

fsn.getBalance("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff","0x9c48c796cb0bed51a14291bc8cc56dab5aed7b5c")
...

getBalance like name assetID the asset ID address the user’s address blockNumber default now block number

Parameters

none

Returns

Object: With the following methods:

  • Object: Description

Example

fsn.getBalance("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff","0x9c48c796cb0bed51a14291bc8cc56dab5aed7b5c")

getNotation

fsn.getNotation("0x9c48c796cb0bed51a14291bc8cc56dab5aed7b5c")
...

getNotation get the notation of address address the account address

Parameters

none

Returns

Object: With the following methods:

  • Object: Description

Example

fsn.getNotation("0x9c48c796cb0bed51a14291bc8cc56dab5aed7b5c")

getTimeLockBalance

fsn.getTimeLockBalance("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff","0x9c48c796cb0bed51a14291bc8cc56ed7b5c")
...

getTimeLockBalance like name assetID the asset ID address the user’s address blockNumber default now block number

Parameters

none

Returns

Object: With the following methods:

  • Object: Description

Example

fsn.getTimeLockBalance("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff","0x9c48c796cb0bed51a14291bc8cc56ed7b5c")

makeSwap

fsn.makeSwap({from:fsn.coinbase,FromAssetID:"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
            ToAssetID:"0xffffffffffffffffffffffffffffffffffffffffffff00000000000000000000",MinToAmount:1,MinFromAmount:2,SwapSize:2,Targes:[]},"123456")
...

makeSwap create a quantum swap CP see the top FromAssetID sell asset id MinFromAmount the min amount of the sell asset ToAssetID buy asset id MinToAmount the min amount of the buy asset SwapSize the max sell package size Targes the address list of the “who can buy” can be null password the owner password

Parameters

none

Returns

Object: With the following methods:

  • Object: Description

Example

fsn.makeSwap({from:fsn.coinbase,FromAssetID:"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
            ToAssetID:"0xffffffffffffffffffffffffffffffffffffffffffff00000000000000000000",MinToAmount:1,MinFromAmount:2,SwapSize:2,Targes:[]},"123456")

recallSwap

fsn.recallSwap({from:fsn.coinbase,SwapID:"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"},"123456")
...

recallSwap destroy a quantum swap and get the asset back CP see the top SwapID the swap ID password the owner password

Parameters

none

Returns

Object: With the following methods:

  • Object: Description

Example

fsn.recallSwap({from:fsn.coinbase,SwapID:"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"},"123456")

takeSwap

fsn.takeSwap({from:fsn.coinbase,SwapID:"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",Size:"0x1"},"123456")
...

takeSwap buy a quantum swap CP see the top SwapID the swap ID Size the package size password the owner password

Parameters

none

Returns

Object: With the following methods:

  • Object: Description

Example

fsn.takeSwap({from:fsn.coinbase,SwapID:"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",Size:"0x1"},"123456")
fsn.getSnapshot( blocknumber )
fsn.getSnapshotHash(blockHas)
web3.fsn.getHexDate = function( d ) {
    return "0x" + (( new Date(d)).getTime() / 1000).toString(16)
};

web3.fsn.hex2a = function( hexData ) {
    hexData = hexData.replace( "0x", "" )
    let hex = hexData.toString();//force conversion
    let str = '';
    for (let i = 0; (i < hex.length && hex.substr(i, 2) !== '00'); i += 2)
        str += String.fromCharCode(parseInt(hex.substr(i, 2), 16));
    return str;
}

Note

This documentation is work in progress and web3-fusion-extend 1.0 stable is not yet released! You can find the current documentation for web3-fusion-extend 0.x.x at.

fsntx

FSNTX commands

personal.unlockAccount( eth.coinbase, "123456" )
var tx = fsntx.buildBuyTicketTx( {from:eth.coinbase} )
tx.from = eth.coinbase
var tx2 = eth.signTransaction( tx )
fsntx.sendRawTransaction(tx2.tx)

sendRawTransaction

fsntx.sendRawTransaction()
...

sendRawTransaction

Parameters

none

Returns

Object: With the following methods:

  • Object: Description

Example

fsntx.sendRawTransaction()

buildGenNotationTx

fsntx.buildGenNotationTx()
...

buildGenNotationTx

Parameters

none

Returns

Object: With the following methods:

  • Object: Description

Example

fsntx.buildGenNotationTx()

genNotation

fsntx.genNotation({from:fsn.coinbase},"123456")
...

genNotation gen a notation for a account CP see the top and the “from” ignore from who gen the notation password the account password

Parameters

none

Returns

Object: With the following methods:

  • Object: Description

Example

fsntx.genNotation({from:fsn.coinbase},"123456")

buildGenAssetTx

fsntx.buildGenAssetTx()
...

buildGenAssetTx

Parameters

none

Returns

Object: With the following methods:

  • Object: Description

Example

fsntx.buildGenAssetTx()

genAsset

fsntx.genAsset({from:fsn.coinbase,name:"FusionTest",symbol:"FST",decimals:1,total:"0x200"},"123456")
fsntx.genAsset({from:"0x91db50f5c36ae7616009d4e94462dca4d4c7e833",name:"JONESY",symbol:"JSY",decimals:1,total:"0x2000000000"},"123123123")
...

genAsset generate a asset CP see the top and the “from” ignore from who gen the asset and the owner of the asset name the name of asset symbol the symbol of asset decimals the asset decimal digit total the total number of the asset and the owner will be get same number asset CanChange whether asset can be incremented or decremented by the owner [optional] password the account password

Parameters

none

Returns

Object: With the following methods:

  • Object: Description

Example

fsntx.genAsset({from:fsn.coinbase,name:"FusionTest",symbol:"FST",decimals:1,total:"0x200"},"123456")
fsntx.genAsset({from:"0x91db50f5c36ae7616009d4e94462dca4d4c7e833",name:"JONESY",symbol:"JSY",decimals:1,total:"0x2000000000"},"123123123")

buildSendAssetTx

fsntx.buildSendAssetTx()
...

buildSendAssetTx

Parameters

none

Returns

Object: With the following methods:

  • Object: Description

Example

fsntx.buildSendAssetTx()

sendAsset

fsntx.sendAsset({from:fsn.coinbase,to:"0x2b1a3eca81ba03a9a4c95f4a04679c90838d7165",value:"0x1",asset:"0x514a46f34e6eb0a98abb3595c4aec33ca8ddf69f135c8fed89e78d0808047965"},"123456")

fsntx.sendAsset({from:fsn.coinbase,to:"0x91db50F5c36aE7616009d4e94462DcA4D4c7e833",value:"0x2",asset:"0x88d18f81620e5684e880dddcf0b6c167a9154d4c499bc9fad47b98634110eeec"},"123456")
...

sendAsset send asset to other account CSP see the top

Parameters

none

Returns

Object: With the following methods:

  • Object: Description

Example

fsntx.sendAsset({from:fsn.coinbase,to:"0x2b1a3eca81ba03a9a4c95f4a04679c90838d7165",value:"0x1",asset:"0x514a46f34e6eb0a98abb3595c4aec33ca8ddf69f135c8fed89e78d0808047965"},"123456")

fsntx.sendAsset({from:fsn.coinbase,to:"0x91db50F5c36aE7616009d4e94462DcA4D4c7e833",value:"0x2",asset:"0x88d18f81620e5684e880dddcf0b6c167a9154d4c499bc9fad47b98634110eeec"},"123456")

buildAssetToTimeLockTx

fsntx.buildAssetToTimeLockTx()
...

buildAssetToTimeLockTx

Parameters

none

Returns

Object: With the following methods:

  • Object: Description

Example

fsntx.buildAssetToTimeLockTx()

assetToTimeLock

fsntx.assetToTimeLock({asset:"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",from:fsn.coinbase,to:"0xa7455DF112c953F3c73c2C25559965e1A8a20024",start:"0x1",end:"0x2A300",value:"0x1400000000000000"},"123456")

fsntx.assetToTimeLock({asset:"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",from:fsn.coinbase,to:"0xa7455DF112c953F3c73c2C25559965e1A8a20024",start:"0x2a900",end:"0x3A300",value:"0x1400000000000000"},"123456")

fsntx.assetToTimeLock({asset:"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",from:fsn.coinbase,to:"0xa7455DF112c953F3c73c2C25559965e1A8a20024",start: getHexDate('2018-12-01') ,end: getHexDate('2019-01-01'),value:"0x1340000000000000"},"123456")
...

assetToTimeLock send the asset to time lock CSP see the top startTime the start time of the time lock endTime the end time of the time lock password the account password

Parameters

none

Returns

Object: With the following methods:

  • Object: Description

Example

fsntx.assetToTimeLock({asset:"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",from:fsn.coinbase,to:"0xa7455DF112c953F3c73c2C25559965e1A8a20024",start:"0x1",end:"0x2A300",value:"0x1400000000000000"},"123456")

fsntx.assetToTimeLock({asset:"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",from:fsn.coinbase,to:"0xa7455DF112c953F3c73c2C25559965e1A8a20024",start:"0x2a900",end:"0x3A300",value:"0x1400000000000000"},"123456")

fsntx.assetToTimeLock({asset:"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",from:fsn.coinbase,to:"0xa7455DF112c953F3c73c2C25559965e1A8a20024",start: getHexDate('2018-12-01') ,end: getHexDate('2019-01-01'),value:"0x1340000000000000"},"123456")

buildTimeLockToTimeLockTx

fsntx.buildTimeLockToTimeLockTx()
...

buildTimeLockToTimeLockTx

Parameters

none

Returns

Object: With the following methods:

  • Object: Description

Example

fsntx.buildTimeLockToTimeLockTx()

timeLockToTimeLock

fsntx.timeLockToTimeLock({asset:"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",from:fsn.coinbase,to:"0x2b1a3eca81ba03a9a4c95f4a04679c90838d7165",start:"0x101",end:"0x200",value:"0x100"},"123456")
...

timeLockToTimeLock send the time lock CSP see the top startTime the start time of the time lock endTime the end time of the time lock password the account password

Parameters

none

Returns

Object: With the following methods:

  • Object: Description

Example

fsntx.timeLockToTimeLock({asset:"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",from:fsn.coinbase,to:"0x2b1a3eca81ba03a9a4c95f4a04679c90838d7165",start:"0x101",end:"0x200",value:"0x100"},"123456")

buildTimeLockToAssetTx

fsntx.buildTimeLockToAssetTx()
...

buildTimeLockToAssetTx

Parameters

none

Returns

Object: With the following methods:

  • Object: Description

Example

fsntx.buildTimeLockToAssetTx()

timeLockToAsset

fsntx.timeLockToAsset({asset:"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",from:fsn.coinbase,to:fsn.coinbase,start:"0x0",end:"0x0",value:"0x100"},"123456")
...

timeLockToAsset send the time lock to asset CSP see the top startTime the start time of the time lock endTime the end time of the time lock password the account password

Parameters

none

Returns

Object: With the following methods:

  • Object: Description

Example

fsntx.timeLockToAsset({asset:"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",from:fsn.coinbase,to:fsn.coinbase,start:"0x0",end:"0x0",value:"0x100"},"123456")

buildBuyTicketTx

fsntx.buildBuyTicketTx()
...

buildBuyTicketTx

Parameters

none

Returns

Object: With the following methods:

  • Object: Description

Example

fsntx.buildBuyTicketTx()

buyTicket

fsntx.buyTicket({from:fsn.coinbase},"123456")
...

buyTicket buy the ticket CP see the top and the “from” ignore from who buy the ticket password the account password

Parameters

none

Returns

Object: With the following methods:

  • Object: Description

Example

fsntx.buyTicket({from:fsn.coinbase},"123456")

buildIncAssetTx

fsntx.buildIncAssetTx()
...

buildIncAssetTx

Parameters

none

Returns

Object: With the following methods:

  • Object: Description

Example

fsntx.buildIncAssetTx()

incAsset

fsntx.incAsset({from:fsn.coinbase,to:"0x2b1a3eca81ba03a9a4c95f4a04679c90838d7165",value:"0x1",asset:"0x514a46f34e6eb0a98abb3595c4aec33ca8ddf69f135c8fed89e78d0808047965"},"123456")
...

incAsset increase account asset balance CSP see the top and the “from”,”to” ignore from the asset owner to the inc account password the account password

Parameters

none

Returns

Object: With the following methods:

  • Object: Description

Example

fsntx.incAsset({from:fsn.coinbase,to:"0x2b1a3eca81ba03a9a4c95f4a04679c90838d7165",value:"0x1",asset:"0x514a46f34e6eb0a98abb3595c4aec33ca8ddf69f135c8fed89e78d0808047965"},"123456")

buildDecAssetTx

fsntx.buildDecAssetTx()
...

buildDecAssetTx

Parameters

none

Returns

Object: With the following methods:

  • Object: Description

Example

fsntx.buildDecAssetTx()

decAsset

fsntx.decAsset({from:fsn.coinbase,to:"0x2b1a3eca81ba03a9a4c95f4a04679c90838d7165",value:"0x1",asset:"0x514a46f34e6eb0a98abb3595c4aec33ca8ddf69f135c8fed89e78d0808047965"},"123456")
...

decAsset decrease account asset balance CSP see the top and the “from”,”to” ignore from the asset owner to the dec account password the account password

Parameters

none

Returns

Object: With the following methods:

  • Object: Description

Example

fsntx.decAsset({from:fsn.coinbase,to:"0x2b1a3eca81ba03a9a4c95f4a04679c90838d7165",value:"0x1",asset:"0x514a46f34e6eb0a98abb3595c4aec33ca8ddf69f135c8fed89e78d0808047965"},"123456")

buildMakeSwapTx

fsntx.buildMakeSwapTx()
...

buildMakeSwapTx

Parameters

none

Returns

Object: With the following methods:

  • Object: Description

Example

fsntx.buildMakeSwapTx()

makeSwap

fsntx.makeSwap({from:fsn.coinbase,FromAssetID:"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
            ToAssetID:"0xffffffffffffffffffffffffffffffffffffffffffff00000000000000000000",MinToAmount:1,MinFromAmount:2,SwapSize:2,Targes:[]},"123456")
...

makeSwap create a quantum swap CP see the top FromAssetID sell asset id MinFromAmount the min amount of the sell asset ToAssetID buy asset id MinToAmount the min amount of the buy asset SwapSize the max sell package size Targes the address list of the “who can buy” can be null password the owner password

Parameters

none

Returns

Object: With the following methods:

  • Object: Description

Example

fsntx.makeSwap({from:fsn.coinbase,FromAssetID:"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
            ToAssetID:"0xffffffffffffffffffffffffffffffffffffffffffff00000000000000000000",MinToAmount:1,MinFromAmount:2,SwapSize:2,Targes:[]},"123456")

buildRecallSwapTx

fsntx.buildRecallSwapTx()
...

buildRecallSwapTx

Parameters

none

Returns

Object: With the following methods:

  • Object: Description

Example

fsntx.buildRecallSwapTx()

recallSwap

fsntx.recallSwap({from:fsn.coinbase,SwapID:"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"},"123456")
...

recallSwap destroy a quantum swap and get the asset back CP see the top SwapID the swap ID password the owner password

Parameters

none

Returns

Object: With the following methods:

  • Object: Description

Example

fsntx.recallSwap({from:fsn.coinbase,SwapID:"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"},"123456")

buildTakeSwapTx

fsntx.buildTakeSwapTx()
...

buildTakeSwapTx

Parameters

none

Returns

Object: With the following methods:

  • Object: Description

Example

fsntx.buildTakeSwapTx()

takeSwap

fsntx.takeSwap({from:fsn.coinbase,SwapID:"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",Size:"0x1"},"123456")
...

takeSwap buy a quantum swap CP see the top SwapID the swap ID Size the package size password the owner password

Parameters

none

Returns

Object: With the following methods:

  • Object: Description

Example

fsntx.takeSwap({from:fsn.coinbase,SwapID:"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",Size:"0x1"},"123456")