0xweb 用于 哈达特
插件生成 0xWeb 使区块链发展具有透明度.
我们用 qq dequanto 图书馆 课程
页:1
安装
自动安装依赖关系和配置
# install 0xweb
$ npm i 0xweb -g
# initialize 0xweb and hardhat project
$ 0xweb init --hardhat
编译
any/directory/Foo.sol
pragma solidity ^0.8.2;
contract Foo {
string public name;
function setName(string memory _name) public {
name = _name;
}
}
插件还增加了指定
sources文件夹。 根据默认,这是/contracts/**.sol
$ npx hardhat compile --sources ./any/directory/
用于地方发展
example.ts
import { Foo } from '0xc/hardhat/Foo/Foo.ts'
import { HardhatProvider } from '@dequanto/hardhat/HardhatProvider'
// automatically deploys the contract to hardhat chain
const deployer = new HardhatProvider();
const foo = await deployer.deployClass<Foo>(Foo, { arguments: [ 'Hello' ] });
// write
const tx = await foo.setName('Hello world')
const receipt = await tx.wait();
// read
const text = await foo.name();
将已部署的合同用于任何链条
如果合同已经部署,将合同与地址初始化为正常类别。 如果合同被部署到其他链条上 -- -- 也将客户设定在构建器中
example.ts
import { Foo } from '0xc/hardhat/Foo/Foo.ts'
import { EthWeb3Client } from '@dequanto/clients/EthWeb3Client'
const client = new EthWeb3Client();
const foo = new Foo('0x12345...', client);
// write
const tx = await foo.setName('Hello world');
const receipt = tx.wait();
// read
const text = await foo.name();
其他参数
npx hardhat compile --sources /foo/bar/qux- 编译位于区域外的固态文件/contracts文件夹npx hardhat compile --artifacts /dist- 设置文物定制文件夹(ABI JSONs和TS合同)npx hardhat compile --watch- 汇编资料来源并等待重新汇编更改npx hardhat compile --package path/to/package/folder- 您可以将您的工程分割成软件包, 通过命令将合同编译成软件包, 源将被搜索到该目录中, 并且将文物输出写入该目录npx hardhat compile --tsgen false- 不要产生TS课程。 安装源目录中的所有合同 .npx hardhat compile --install TimelockController- 只安装指定的艺术名称或 *.sol路径 。 逗号分离.