本文整理匯總了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;