本文整理汇总了TypeScript中web3.toWei函数的典型用法代码示例。如果您正苦于以下问题:TypeScript toWei函数的具体用法?TypeScript toWei怎么用?TypeScript toWei使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了toWei函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: beforeEach
beforeEach(async () => {
await token.setPrice(
secondProduct.id,
web3.toWei(new BigNumber(1), 'ether'),
{
from: creator
}
);
secondProduct.price = web3.toWei(new BigNumber(1), 'ether').toNumber();
});
开发者ID:JalelTounsi,项目名称:dotta-license,代码行数:10,代码来源:AffiliateProgram.test.ts
示例2: describe
describe('when calculating cuts for an affiliate', async () => {
const priceTests = [
{
price: web3.toWei(1, 'ether'),
rate: 1000,
actual: web3.toWei(0.1, 'ether')
},
{
price: web3.toWei(0.5, 'ether'),
rate: 2500,
actual: web3.toWei(0.125, 'ether')
},
{
price: 1000,
rate: 2,
actual: 0
},
{
price: 1234,
rate: 123,
actual: 15
},
{
price: 1234,
rate: 129,
actual: 15
}
];
priceTests.forEach(test => {
it(`should calculate the correct cut for price ${
test.price
} at rate ${test.rate / 100}%`, async () => {
await affiliate.whitelist(affiliate1, test.rate, { from: creator });
const givenCut = await affiliate.cutFor(
affiliate1,
0,
0,
test.price,
{
from: creator
}
);
givenCut.should.be.bignumber.equal(new BigNumber(test.actual));
});
});
});
开发者ID:JalelTounsi,项目名称:dotta-license,代码行数:47,代码来源:AffiliateProgram.test.ts
示例3: before
before(async () => {
const contracts = JSON.parse((await readFileAsync(path.join(__dirname, 'contracts.json'))).toString());
accounts = await promisify<string[]>(web3.eth, 'getAccounts')();
sender = accounts[0];
receiver = accounts[1];
// deploy token contract with last account
const Token = web3.eth.contract(contracts[TOKEN]['abi']);
let token = await new Promise<Web3.ContractInstance>((resolve, reject) =>
Token.new(
TOKEN_SUPLY,
TOKEN,
'TKN',
DECIMALS,
{
gas: 5e6,
from: accounts[accounts.length-1],
data: contracts[TOKEN]['bytecode'],
},
(err, contract) => {
if (err)
return reject(err);
else if (contract.address)
return resolve(contract);
}
)
);
// mint 50 tkns to sender and receiver
for (let acc of [sender, receiver]) {
promisify<string>(token.mint, 'sendTransaction')({
from: acc,
value: web3.toWei(0.1, 'ether'),
});
}
// deploy channel manager contract with last account and token
const ChannelManager = web3.eth.contract(contracts[CHANNEL_MANAGER]['abi']);
let channel_manager = await new Promise<Web3.ContractInstance>((resolve, reject) =>
ChannelManager.new(
token.address,
CHALLENGE_PERIOD,
[],
{
gas: 5e6,
from: accounts[accounts.length-1],
data: contracts[CHANNEL_MANAGER]['bytecode'],
},
(err, contract) => {
if (err)
return reject(err);
else if (contract.address)
return resolve(contract);
}
)
);
expect(token.address).to.match(addr_re);
expect(channel_manager.address).to.match(addr_re);
// init uraiden
uraiden = new MicroRaiden(
web3,
channel_manager.address,
channel_manager.abi,
token.address,
token.abi,
);
});
开发者ID:AlphaX-IBS,项目名称:microraiden,代码行数:69,代码来源:microraiden.ts
示例4: toWei
public toWei(ethAmount: BigNumber.BigNumber): BigNumber.BigNumber {
const balanceWei = this.web3.toWei(ethAmount, 'ether');
return balanceWei;
}
开发者ID:linki,项目名称:0x.js,代码行数:4,代码来源:web3_wrapper.ts
注:本文中的web3.toWei函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论