Release notes

v2.0.7

  • Fix logFilter formater bug

v2.0.6

  • Fix contract method batch call bug

v2.0.3

  • Change trace epochNumber, transactionPosition from BigInt to Int
  • Add field totalEspaceTokens in getSupplyInfo's response

v2.0.0

  • Add support for PoS RPC methods
  • Split RPC methods to it's own namespace, currently include: cfx, pos, trace, txpool
  • Add support for batch RPC
  • Browser export class name change from Conflux to TreeGraph
  • Add method getNextUsableNonce to conflux.advanced, which will first try to use txpool_nextNonce to get a usable nonce, if failed it will fall back to cfx_getNextNonce
  • Add three internal contracts CrossSpaceCall, ConfluxContext, PoSRegister
  • Add one method cfxMappedEVMSpaceAddress to address utility.

trace updates

  • Add a new boolean field valid to indicate whether this trace has change state
  • The internal_transfer_action type trace has added four new field fromPocket, toPocket, fromSpace, toSpace
  • The call and create type trace has added one new field space
For detail explanation of the trace updates check this doc.
Check v2.0 changes for change details

Provider API

  • Add provider.request to make provider compliant with EIP-1193
  • Add a new provider WechatProvider which can be used in Wechat environment
Here is the complete Conflux-rust v2.0 RPC change overview

v1.7.2

  • Add balance key in the result of estimateGasAndCollateralAdvance as the balance of options.from.

v1.7.1

  • Add method checkBalanceAgainstTransaction, and estimateGasAndCollateralAdvance to better estimate gas and check balance.

v1.6.15

  • Add blockNumber to block related methods cfx_getBlockByHash, cfx_getBlockByEpochNumber, cfx_getBlockByHashWithPivotAssumption which need Conflux-rust v1.1.5 or above.
  • Add one new RPC method cfx_getBlockByBlockNubmer

v1.6.10

  • format.bytes now only support hex string, will not accept non hex utf-8 string
  • Add cli cfxjs which can random generate a 0x1 prefix ethereum address
  • Conflux add a new method getEpochReceiptsByPivotBlockHash

v1.6.9

  • Support keepAlive option in Conflux initialization.
  • Add one util method tracesInTree to return a tree structure traces.
  • Fix contract method override bug.
  • Add a address utility method shortenCfxAddress.

v1.6.3

  • Support retry option in Conflux initialization.
  • Add pending transaction status enum CONST.PENDING_TX_STATUS currently have two value: FUTURE_NONCE NOT_ENOUGH_CASH

v1.6.2

  • Optimize the address convert performance.

v1.6.1

  • Conflux add method getAccountPendingTransactions to get one account's pending transaction.
  • Split API documents into several files, which is easy to read.

v1.6.0

This version is corresponding to conflux-rust v1.1.3, check it's changelog for detailed info.
  • format.address will respect networkId, verbose flag even if the first parameter is an CIP37 address.
  • Add support for a standard token contract through Conflux.CRC20
  • cfx_getLogs filter option add one more field offset
  • Add one RPC method cfx_getAccountPendingInfo to get account's transaction pending info
  • epochs pubsub now accept one parameter subscription_epoch the supported values are latest_mined (default) and latest_state
  • Include blockHash, epochHash, epochNumber, transactionHash, and transactionPosition for trace RPCs
  • When ABI encoding bytes-N type, if the data's length is not enough, will auto pad (right) to N

v1.5.13

  • getStatus method rethurn three new fields latestState, latestConfirmed, latestCheckpoint
  • add two trace related rpc traceTransaction, traceFilter
  • add one debug rpc getEpochReceipts
  • add two provider wrapper wrapEthereum, wrapConflux to work with metamask
Notice: this is an update corresponding conflux-rust v1.1.2

v1.5.10

  • Conflux's option can pass networkId now, and add a new method updateNetworkId to sync networkId from RPC.
  • format.address will return new CIP37 addresses, if you pass a hex address, networkId should also be passed as second parameter
  • add new method format.hexAddress to format hex address
  • Wallet's constructor add a parameter networkId
  • PrivateKeyAccount constructor, decrypt, random need one more parameter networkId
  • Transaction, Message sign method need one more parameter networkId
  • Conflux's get methods will return new address, and same to contract method returned address.
  • getSupplyInfo response add new field totalCirculating
  • getStatus response add new field networkId

v1.1.7

  • Add RPC method traceBlock to Conflux which can used to get block's execution trace

v1.1.6

  • export Contract
1
// nodejs
2
const { Contract } = require('js-conflux-sdk');
Copied!
1
import { Contract } from 'js-conflux-sdk'
Copied!

v1.1.5

  • add stateMutability for method from abi
1
console.log(contract.symbol.stateMutability) // "view"
2
console.log(contract.transfer.stateMutability) // "nonpayable"
Copied!
  • rename EventLog.params to EventLog.arguments
1
await conflux.contract.Transfer(null, null, null).getLogs({
2
fromEpoch: 2868400,
3
toEpoch: 2868500,
4
});
5
6
/* [
7
{
8
data: '0x0000000000000000000000000000000000000000000000000001184b321b4e44',
9
topics: [ '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef', '0x0000000000000000000000001dc05200485776b79f195a1e617dbccb6826f1c4', '0x000000000000000000000000882c4ddb1d3210b5ae778360729c04cd3242df70' ],
10
...,
11
arguments: NamedTuple(from,to,value)(3) [ '0x1dc05200485776b79f195a1e617dbccb6826f1c4', '0x882c4ddb1d3210b5ae778360729c04cd3242df70', 308186218974788n ]
12
}
13
] */
Copied!
  • add subscribeLogs for EventLog
1
subscription = await contract.Transfer(null, null, null).subscribeLogs();
2
subscription.on('data', data => { console.log(data); });
Copied!
  • contract decode constructor data with out bytecode

v1.1.4

  • add conflux.getSupplyInfo

v1.1.3

  • WebsocketProvider with Websocket options
1
new Conflux({ url: 'ws://127.0.0.1', clientConfig: { maxReceivedFrameSize: 10_1000_1000 } }) // 10 MB
Copied!

v1.1.2

  • add conflux.getVoteList
  • add conflux.getDepositList
  • update conflux.getTransactionReceipt

v1.1.1

fix: update request id avoid repeat
1
// old
2
conflux.provider.requestId(); // "16055917399420726"
3
// new
4
conflux.provider.requestId(); // "175d4b91862001f4f81eb443"
Copied!

v1.1.0

fix: use native websocket for front-end
  • use BigInt for nodejs, JSBI for browser
1
// for nodejs
2
// old
3
conflux.getBalance(ADDRESS); // JSBI(1) [ -1153374696, sign: false ]
4
// new
5
conflux.getBalance(ADDRESS); // 3141592600n
Copied!

v1.0.1

fix: EventCoder, FunctionCoder, valueCoder decode return string but not JSBI

v1.0.0

  • add defaultGasRatio and defaultStorageRatio
1
conflux = new Conflux({ defaultGasRatio: 1.1, defaultStorageRatio: 1.1, ... })
Copied!
  • add BaseAccount and PrivateKeyAccount
Account signTransaction and signMessage to be async
  • add wallet
wallet use for create and manage Account by address
1
account = conflux.wallet.addRandom();
2
console.log(conflux.wallet.has(account.address));
3
// true
4
account = conflux.wallet.addPrivateKey(PRIVATE_KEY);
5
console.log(conflux.wallet.has(account.address));
6
// true
7
account = conflux.wallet.addKeystore(keystore, password);
8
console.log(conflux.wallet.has(account.address));
9
// true
Copied!
wallet use for sendTransaction
1
// old
2
account = conflux.Account(PRIVATE_KEY);
3
conflux.sendTransaction({ from: account.address, ...}) // address will call `cfx_sendTranscion`
4
conflux.sendTransaction({ from: account, ... }) // must be instance of `Account` to sign by sdk and call `cfx_sendRawTransaction`
5
6
// new
7
conflux.sendTransaction({ from: address, ... }) // if address not in `conflux.wallet`, call `cfx_sendTranscion`
8
account = conflux.wallet.addPrivate(PRIVATE_KEY);
9
conflux.sendTransaction({ from: account.address, ... }) // if account in `conflux.wallet`, sign by account and call `cfx_sendRawTransaction`
10
conflux.sendTransaction({ from: account, ... }) // same as `from: account.address`, but some user think input account instance with privateKey is unsafe
Copied!
  • add Subscription
1
await conflux.subscribe(name, ...args); // => id
2
await conflux.subscribeEpochs(); // => Subscription with event 'data'
3
await conflux.subscribeNewHeads(); // => Subscription with event 'data'
4
await conflux.subscribeLogs(); // => Subscription with event 'data', 'revert'
5
await conflux.unsubscribe(id); // => boolean
6
await conflux.unsubscribe(subscription); // => boolean
Copied!
  • add internal contract
1
contract = conflux.InternalContract('AdminControl');
2
console.log(contract);
3
contract = conflux.InternalContract('SponsorWhitelistControl');
4
console.log(contract);
5
contract = conflux.InternalContract('Staking');
6
console.log(contract);
Copied!
  • add checksum address
1
// old
2
conflux.getBalance('0x1B716c51381e76900EBAA7999A488511A4E1fD0a'); // ok
3
conflux.getBalance('0x1B716c51381e76900EBAA7999A488511A4E1fD0A'); // ok
4
5
// new
6
conflux.getBalance('0x1B716c51381e76900EBAA7999A488511A4E1fD0a'); // ok
7
conflux.getBalance('0x1B716c51381e76900EBAA7999A488511A4E1fD0A'); // Error\('address checksum error'\)
Copied!
  • providerFactory only accept first argument as override options
1
// old
2
provider = providerFactory('http://localhost:12537')
3
// new
4
provider = providerFactory({ url: 'http://localhost:12537' })
Copied!
  • add batch request
1
provider = providerFactory({ url: 'http://localhost:12537' })
2
array = await provider.batch([ { method: 'cfx_epochNumber' }, { method: 'cfx_getBalance', params: ['0x0123456789012345678901234567890123456789'] }])
3
// [ '0x1381', '0x0']
Copied!
  • add WebSocketProvider
1
provider = providerFactory({ url: 'ws://localhost:12535' })
2
provider.close(); // user need to close before process ternimal
Copied!
  • BaseProvider instanceof EventEmitter
1
const EventEmitter = require('events');
2
3
// old
4
console.log(new BaseProvider() instanceof EventEmitter); // false
5
console.log(new HttpProvider() instanceof EventEmitter); // false
6
7
// new
8
console.log(new BaseProvider({}) instanceof EventEmitter); // true
9
console.log(new HttpProvider({}) instanceof EventEmitter); // true
10
console.log(new WebSocketProvider({}) instanceof EventEmitter); // true
Copied!
  • add CONST
1
const { CONST } = require('js-conflux-sdk');
2
console.log(CONST.EPOCH_NUMBER)
3
{
4
LATEST_MINED: 'latest_mined',
5
LATEST_STATE: 'latest_state',
6
LATEST_CONFIRMED: 'latest_confirmed',
7
LATEST_CHECKPOINT: 'latest_checkpoint',
8
EARLIEST: 'earliest'
9
}
Copied!
  • export format and sign without util
1
// old
2
const { util: {format, sign} } = require('js-conflux-sdk');
3
// new
4
const { format, sign } = require('js-conflux-sdk');
Copied!
  • add Drip to replace unit
1
// old
2
const { util } = require('js-conflux-sdk');
3
const balance = await conflux.getBalance(ADDRESS);
4
console.log(util.unit.fromDripToCFX(balance))
5
6
// new
7
const { Drip } = require('js-conflux-sdk');
8
const balance = await conflux.getBalance(ADDRESS);
9
console.log(Drip(balance).toCFX())
Copied!
for input, use Drip.fromXXX to get drip number string
1
// old
2
const { util } = require('js-conflux-sdk');
3
const tx = { to: ADDRESS, value: util.unit.fromCFXToDrip(0.1), ... }
4
5
// new
6
const { Drip } = require('js-conflux-sdk');
7
const tx = { to: ADDRESS, value: Drip.fromCFX(0.1), ... }
Copied!
  • include all method from conflux JSON_RPC document
JSON_RPC
  • friendly example code
example will guide user to use SDK step by step
  • charming code organization
split abi coder with types
split contract method, event and override

v0.13.4

  • rename send_transaction to cfx_sendTransaction

v0.13.3

  • Account.encrypt returned address drop '0x' prefix

v0.13.2

  • use scrypt-js

v0.13.1

  • RPC returned all number as hex
  • fix sendTransaction, call, estimateGasAndCollateral shallow copy options

v0.13.0

  • Account.decrypt required keystoreV3 object as input, and put password as second parameter
1
// old
2
Account.decrypt('password', {salt:..., iv:..., cipher:..., mac:...})
3
4
// new
5
Account.decrypt({
6
version: 3,
7
id: '0bb47ee0-aac3-a006-2717-03877afa15f0',
8
address: '0x1cad0b19bb29d4674531d6f115237e16afce377c',
9
crypto: {
10
ciphertext: 'a8ec41d2440311ce897bacb6f7942f3235113fa17c4ae6732e032336038a8f73',
11
cipherparams: { iv: '85b5e092c1c32129e3d27df8c581514d' },
12
cipher: 'aes-128-ctr',
13
kdf: 'scrypt',
14
kdfparams: { dklen: 32, salt: 'b662f09bdf6751ac599219732609dceac430bc0629a7906eaa1451555f051ebc', n: 8192, r: 8, p: 1 },
15
mac: 'cc89df7ef6c27d284526a65cabf8e5042cdf1ec1aa4ee36dcf65b965fa34843d'
16
}
17
},
18
'password')
Copied!
  • Account.prototype.encrypt returned keystoreV3 format object
1
const account = new Account('0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef');
2
3
// old
4
account.encrypt('password')
5
/*
6
{
7
algorithm: 'aes-128-ctr',
8
N: 8192,
9
r: 8,
10
p: 1,
11
dkLen: 32,
12
salt: '0xb662f09bdf6751ac599219732609dceac430bc0629a7906eaa1451555f051ebc',
13
iv: '0x85b5e092c1c32129e3d27df8c581514d',
14
cipher: '0xa8ec41d2440311ce897bacb6f7942f3235113fa17c4ae6732e032336038a8f73',
15
mac: '0xcc89df7ef6c27d284526a65cabf8e5042cdf1ec1aa4ee36dcf65b965fa34843d'
16
}
17
*/
18
19
// new
20
account.encrypt('password')
21
/*
22
{
23
version: 3,
24
id: '0bb47ee0-aac3-a006-2717-03877afa15f0',
25
address: '0x1cad0b19bb29d4674531d6f115237e16afce377c',
26
crypto: {
27
ciphertext: 'a8ec41d2440311ce897bacb6f7942f3235113fa17c4ae6732e032336038a8f73',
28
cipherparams: {
29
iv: '85b5e092c1c32129e3d27df8c581514d'
30
},
31
cipher: 'aes-128-ctr',
32
kdf: 'scrypt',
33
kdfparams: {
34
dklen: 32,
35
salt: 'b662f09bdf6751ac599219732609dceac430bc0629a7906eaa1451555f051ebc',
36
n: 8192,
37
r: 8,
38
pw: 1
39
},
40
mac: 'cc89df7ef6c27d284526a65cabf8e5042cdf1ec1aa4ee36dcf65b965fa34843d'
41
}
42
}
43
*/
Copied!
  • epochNumber accept earliest, latest_checkpoint, latest_confirmed label

v0.12.0

  • add getAdmin
1
await cfx.getAdmin('0x89996a8aefb2228593aae723d47f9517eef1341d') // "0x1be45681ac6c53d5a40475f7526bac1fe7590fb8"
Copied!
  • sendTransaction accept privateKey as from
1
cfx.sendTransaction({
2
from: PRIVATE_KEY, // accept Account instance or privateKey
3
to: ADDRESS, // accept Account instance or address
4
...,
5
})
Copied!
  • create Account accept address
1
new Account(PRIVATE_KEY); // {privateKey:'0x...', publicKey: '0x...', address: '0x...'}
2
new Account(PUBLIC_KEY); // {publicKey: '0x...', address: '0x...'}
3
new Account(ADDRESS); // {address: '0x...'}
Copied!

v0.11.0

  • defaultGasPrice, only use for sendTransaction
1
cfx = new Conflux({ url: 'https://test.confluxrpc.com', defaultGasPrice: 100, });
2
// old
3
cfx.call({ address: '0x...', data: '0x...', }); // => cfx_call{defaultGasPrice:'0x64',address:'0x...',data:'0x...'}
4
// new
5
cfx.call({ address: '0x...', data: '0x...', }); // => cfx_call{address:'0x...',data:'0x...'}
Copied!
  • remove defaultEpoch, defaultChainId, defaultGas, defaultStorageLimit
1
// old
2
cfx = new Conflux({ url: 'https://test.confluxrpc.com', defaultEpoch: 'latest_state', defaultChainId: 1, defaultGasPrice: 100, defaultGas: 10, defaultStorageLimit: 1, })
3
4
// new
5
cfx = new Conflux({ url: 'https://test.confluxrpc.com', defaultGasPrice: 100, })
6
7
// user could `epochNumber` and `chainId` manual on each method.
Copied!

v0.10.3

  • fix broken sourcemap

v0.10.2

  • fix: include crypto into browserify build
1
// old
2
ConfluxJSSDK.util.sign.randomPrivateKey() // TypeError randomBytes is not a function
Copied!

v0.10.1

  • add format.bytes
1
format.bytes('abcd'); // format.bytes([0, 1, 2, 3]);
Copied!
  • add contract method & event type or signature indexes
1
// solidity function override(bytes memory str) public function override(string memory str) public
2
contract.override('str'); // Error: can not determine override
3
contract['override(string)']('str'); // specify override method by type contract['0x227ffd52']('str'); // specify override method by signature
Copied!

v0.10.0-alpha

  • add getStatus
1
cfx.getStatus()
Copied!
  • remove getRiskCoefficient and replace with getConfirmationRiskByHash
1
// old
2
cfx.getRiskCoefficient(epochNumber)
3
// new
4
cfx.getConfirmationRiskByHash(blockHash)
Copied!
  • remove getAccount cause it's internal RPC.
  • use require replace import to gen code.

v0.9.2

  • add defaultStorageLimit and defaultChainId for Conflux
1
// old
2
const cfx = new Conflux({ url: 'https://test.confluxrpc.com', defaultGasPrice: 100, defaultGas: 100000, })
3
// new
4
const cfx = new Conflux({ url: 'https://test.confluxrpc.com', defaultGasPrice: 100, defaultGas: 100000, defaultStorageLimit: 4096, defaultChainId: 0, })
Copied!

v0.9.1

  • abi implicitly converting string to number
solidity method: function add(uint,uint) public returns (uint);
1
// old
2
await contract.add(1, '2'); // error! can not accept string
3
// new version
4
await contract.add(1, '2'); // good, converting string to number
Copied!

v0.9.0-beta

  • format nonce as JSBI.BigInt
1
nonce = await cfx.getNextNonce(...)
2
// old 100000
3
// new JSBI.BigInt(100000)
Copied!
  • format transaction fields
1
tx = await cfx.getTransactionByHash(txHash)
2
// old
3
{ storageLimit: "0x64", chainId: "0x0", epochHeight: "0x400", ... }
4
// new
5
{
6
storageLimit: JSBI.BigInt(100), // JSBI
7
chainId: 0,
8
epochHeight: 1024, ...
9
}
Copied!
  • unit return string
1
// old
2
unit.fromCFXToGDrip(123) => JSBI.BigInt(123000000000)
3
unit.fromCFXToGDrip('0.1234567891') => Error('Cannot convert JSBI.BigInt')
4
// new
5
unit.fromCFXToGDrip(123) => "123000000000"
6
unit.fromCFXToGDrip('0.1234567891') => "123456789.1"
Copied!
  • contract fields "code" rename to "bytecode"
1
// old
2
cfx.Contract({code, abi, address})
3
// new
4
cfx.Contract({bytecode, abi, address})
Copied!
  • abi decodeData and decodeLog return object
1
result = contract.abi.decodeData('0x....')
2
// old
3
["Tom", JSBI.BigInt(18)]
4
// new
5
{ name: 'func' fullName: 'func(string name, uint age)', type: 'func(string,uint)', signature: '0x812600df', array: ["Tom", JSBI.BigInt(18)], object: { name: "Tom", age: JSBI.BigInt(18), } }
Copied!
Last modified 1mo ago