本文整理汇总了TypeScript中ethers.ethers.utils.parseEther方法的典型用法代码示例。如果您正苦于以下问题:TypeScript ethers.utils.parseEther方法的具体用法?TypeScript ethers.utils.parseEther怎么用?TypeScript ethers.utils.parseEther使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ethers.ethers.utils
的用法示例。
在下文中一共展示了ethers.utils.parseEther方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it("generates a correct transaction", async () => {
const appInterface = new cf.legacy.app.AppInterface(
"0xDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD",
"0x00000000",
"0x00000000",
"0x00000000",
"0x00000000",
"tuple()"
);
const terms = new cf.legacy.app.Terms(
AssetType.ETH,
ethers.utils.parseEther("1"),
ethers.constants.AddressZero
);
const cfApp = new cf.legacy.app.AppInstance(
fakeCtx,
multisig,
[alice, bob],
appInterface,
terms,
100,
0
);
const fakeNonce = new cf.legacy.utils.Nonce(false, 0, 0);
const freeBal = new cf.legacy.utils.FreeBalance(
alice,
ethers.utils.parseEther("0.5"),
bob,
ethers.utils.parseEther("0.5"),
1,
0,
100,
fakeNonce
);
const op = new OpSetup(fakeCtx, multisig, cfApp, freeBal, fakeNonce);
const transaction = op.transaction([]);
expect(transaction.to).toBe(multisig);
expect(transaction.value).toBe(0);
const txSighash = transaction.data.slice(0, 10);
const expectedSighash = new ethers.utils.Interface(
MinimumViableMultisigJson.abi
).functions.execTransaction.sighash;
expect(txSighash).toBe(expectedSighash);
});
示例2: async
import { ethers } from "ethers";
export const UNIT_ETH = ethers.utils.parseEther("1");
export const HIGH_GAS_LIMIT = { gasLimit: 6e9 };
export const deployContract = async (
contract: any,
wallet: ethers.Wallet,
args?: any[]
): Promise<ethers.Contract> => {
const contractFactory = new ethers.ContractFactory(
contract.abi,
contract.binary,
wallet
);
return contractFactory.deploy(...(args || []));
};
export const getDeployedContract = async (
contract: any,
providerOrSigner: ethers.Wallet | ethers.providers.Provider
): Promise<ethers.Contract> => {
return new ethers.Contract(
(await contract.deployed()).address,
contract.abi,
providerOrSigner
);
};
export const randomETHAddress = (): string =>
ethers.utils.hexlify(ethers.utils.randomBytes(20));
示例3:
new ethers.utils.SigningKey(
"0x3570f77380e22f8dc2274d8fd33e7830cc2d29cf76804e8c21f4f7a6cc571d27"
),
// 0xb37e49bFC97A948617bF3B63BC6942BB15285715
new ethers.utils.SigningKey(
"0x4ccac8b1e81fb18a98bbaf29b9bfe307885561f71b76bd4680d7aec9d0ddfcfd"
)
];
export const TEST_PARTICIPANTS = [
TEST_SIGNING_KEYS[0].address,
TEST_SIGNING_KEYS[1].address
];
export const TEST_APP_UNIQUE_ID = 13;
export const TEST_TERMS = new cf.legacy.app.Terms(
0,
ethers.utils.parseEther("1.0"),
ethers.constants.AddressZero
);
export const TEST_APP_INTERFACE = new cf.legacy.app.AppInterface(
ethers.constants.AddressZero,
"0x00000000",
"0x00000000",
"0x00000000",
"0x00000000",
"tuple(address,uint256)"
);
export const TEST_APP_STATE_HASH = ethers.utils.hexlify(
"0x9999999999999999999999999999999999999999999999999999999999999999"
);
export const TEST_LOCAL_NONCE = 0;
export const TEST_TIMEOUT = 100;