1.0.11 • Published 3 years ago

aiot-js v1.0.11

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

npm

npm install aiot-js

引用

const AIOT = request('aiot-js');

随机生成地址

const keyPair = AIOT.ec.fromEntropy();
console.log('-----', '随机生成');
console.log('privateKey', keyPair.privateKey.toString('hex'));
console.log('publicKey', keyPair.publicKey.toString('hex'));
console.log('WIF', keyPair.toWIF());

根据私钥生成

const privateKey = '';
const keyPair = AIOT.ec.fromPrivateKey(Buffer.from(privateKey, 'hex'));
console.log('-----', '根据私钥生成');
console.log('privateKey', keyPair.privateKey.toString('hex'));

根据WIF私钥生成

const privateKeyWIF = '';
const keyPair = AIOT.ec.fromWIF(privateKeyWIF);
console.log('-----', '根据WIF私钥生成');
console.log('privateKey', keyPair.privateKey.toString('hex'));
console.log('WIF', keyPair.toWIF());

生成地址

const address = AIOT.address.toAddress(keyPair.publicKey, AIOT.networks.testnet);
console.log('-----', '生成地址');
console.log('address', address)

发送交易

const params = {
    type: 0,
    from: '',
    token: 'AIOT',//合约地址,主币:AIOT
    nonce: 0,
    fee: 20000,
    receivers: [{
        address: '',
        amount: 100000000,
    }],
};
const privateKey = '';
const raw = AIOT.tx_v2.sign(privateKey , params);

发送交易 new

const privateKey = '';
const nonce = 0;
const contract = '';
const fees = 20000;
const to = '';
const amount = 100000000;
const raw = AIOT.tx_v2.trading_1vs1(privateKey,nonce,contract,fees,to,amount,network?);

创建交易所

const privateKey = '';
const nonce = 0;
const admin = '交易所管理员';
const feeTo = '手续费管理员';
const raw = AIOT.tx_v2.exchange_publish(privateKey,nonce,admin,feeTo,network?);

添加流动性

const privateKey = '';
const nonce = 0;
const exchange = '交易所';
const tokenA = 'Token A Contract';
const tokenB = 'Token B Contract';
const to = '谁能赎回,流动性';
const amountADesired = 0;//期望金额A
const amountBDesired = 0;//期望金额A
const amountAMin = 0;//最小金额A
const amountBMin = 0;//最小金额B
const deadline = 0;//截止高度
const raw = AIOT.tx_v2.exchange_liquidity_add(privateKey,nonce,exchange,tokenA,tokenB,to, amountADesired, amountBDesired, amountAMin, amountBMin, deadline = 0, network?);

移除流动性

const privateKey = '';
const nonce = 0;
const exchange = '交易所';
const tokenA = 'Token A Contract';
const tokenB = 'Token B Contract';
const to = '接收地址';
const liquidity = 0;//流动性
const amountBMin = 0;//最小金额A
const amountBMin = 0;//最小金额B
const deadline = 0;//截止高度
const raw = AIOT.tx_v2.exchange_liquidity_remove(privateKey, nonce, exchange, tokenA, tokenB, to, liquidity, amountAMin, amountBMin, deadline = 0, network?);

精确的输入兑换输出

const privateKey = '';
const nonce = 0;
const exchange = '交易所';
const amountIn = 0;
const amountOutMin = 0;
const path = array<string>;
const to = '';
const deadline = 0;//截止高度
const raw = AIOT.tx_v2.exchange_swap_in(privateKey, nonce, exchange, amountIn, amountOutMin, path = [], to, deadline = 0, network?);

精确的输出兑换输入

const privateKey = '';
const nonce = 0;
const exchange = '交易所';
const amountOut = 0;
const amountInMax = 0;
const path = array<string>;
const to = '';
const deadline = 0;//截止高度
const raw = AIOT.tx_v2.exchange_swap_out(privateKey, nonce, exchange, amountIn, amountOutMin, path = [], to, deadline = 0, network?);
1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.11

3 years ago

1.0.10

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago