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;
}