@0xproject/asset-buyer 中文文档教程
@0xproject/asset-buyer
警告:在 Beta 版中,尚未经过广泛测试。
使用 0x 购买以太坊区块链上代表的资产的便利包。 在最简单的形式中,该包有助于使用 0x 转发器合约,它允许用户执行基于 Wrapped Ether 的 0x 订单,而无需设置津贴、wrap Ether 或拥有 ZRX,这意味着他们可以购买仅使用以太币的代币。 给定一些流动性(0x 签名订单),它有助于估计购买某种资产(给出范围)然后购买该资产的 Ether 成本。
在其更高级和有用的形式中,它与 Standard Relayer API 集成,并负责为您提供流动性来源符合 SRA 的端点。 最终结果是一个库,它告诉你有哪些资产可用,为任何所需资产提供基于 Ether 的报价,并允许你仅使用 Ether 购买该资产。
Installation
yarn add @0xproject/asset-buyer
导入
import { AssetBuyer } from '@0xproject/asset-buyer';
或者
var AssetBuyer = require('@0xproject/asset-buyer').AssetBuyer;
如果您的项目是 TypeScript,请将以下内容添加到您的 tsconfig.json:
"compilerOptions": {
"typeRoots": ["node_modules/@0xproject/typescript-typings/types", "node_modules/@types"],
}
Contributing
我们欢迎来自更广泛社区的改进和修复! 要报告此包中的错误,请在此存储库中创建一个问题。
请在开始之前阅读我们的贡献指南。
Install dependencies
如果您没有启用 yarn workspaces (Yarn < v1.0) - 启用它们:
yarn config set workspaces-experimental true
然后安装依赖
yarn install
Build
项 要构建此包和它所依赖的所有其他 monorepo 包,请从 monorepo 根目录运行以下命令:
PKG=@0xproject/asset-buyer yarn build
或持续重建关于改变:
PKG=@0xproject/asset-buyer yarn watch
Clean
yarn clean
Lint
yarn lint
Run Tests
yarn test
@0xproject/asset-buyer
Warning: In Beta, has not been extensively tested.
Convenience package for buying assets represented on the Ethereum blockchain using 0x. In its simplest form, the package helps in the usage of the 0x forwarder contract, which allows users to execute Wrapped Ether based 0x orders without having to set allowances, wrap Ether or own ZRX, meaning they can buy tokens with Ether alone. Given some liquidity (0x signed orders), it helps estimate the Ether cost of buying a certain asset (giving a range) and then buying that asset.
In its more advanced and useful form, it integrates with the Standard Relayer API and takes care of sourcing liquidity for you given an SRA compliant endpoint. The final result is a library that tells you what assets are available, provides an Ether based quote for any asset desired, and allows you to buy that asset using Ether alone.
Installation
yarn add @0xproject/asset-buyer
Import
import { AssetBuyer } from '@0xproject/asset-buyer';
or
var AssetBuyer = require('@0xproject/asset-buyer').AssetBuyer;
If your project is in TypeScript, add the following to your tsconfig.json
:
"compilerOptions": {
"typeRoots": ["node_modules/@0xproject/typescript-typings/types", "node_modules/@types"],
}
Contributing
We welcome improvements and fixes from the wider community! To report bugs within this package, please create an issue in this repository.
Please read our contribution guidelines before getting started.
Install dependencies
If you don't have yarn workspaces enabled (Yarn < v1.0) - enable them:
yarn config set workspaces-experimental true
Then install dependencies
yarn install
Build
To build this package and all other monorepo packages that it depends on, run the following from the monorepo root directory:
PKG=@0xproject/asset-buyer yarn build
Or continuously rebuild on change:
PKG=@0xproject/asset-buyer yarn watch
Clean
yarn clean
Lint
yarn lint
Run Tests
yarn test