forked from tornado-packages/ethers.js
Compare commits
81 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bf481f4bbf | ||
|
|
681f2a50b2 | ||
|
|
18fdb96fe1 | ||
|
|
35b64b9a65 | ||
|
|
4ca98825d4 | ||
|
|
0558bba8eb | ||
|
|
a440317594 | ||
|
|
2359a98641 | ||
|
|
a32fbd835d | ||
|
|
6fd3bb62d1 | ||
|
|
83db8a6bd1 | ||
|
|
f24240eddf | ||
|
|
d01d0c8448 | ||
|
|
d3b473e7c7 | ||
|
|
57eb5b777e | ||
|
|
240aac5683 | ||
|
|
8abdbbbf63 | ||
|
|
5fcd03f27e | ||
|
|
cb8f4a3a4e | ||
|
|
8facc1a530 | ||
|
|
17fdca8994 | ||
|
|
df0caab5d6 | ||
|
|
9733927f82 | ||
|
|
28dbcfc38c | ||
|
|
bb8e77dc70 | ||
|
|
ae619bcfc7 | ||
|
|
5b5904ea99 | ||
|
|
8f4b3027ef | ||
|
|
e9009631d5 | ||
|
|
be273f26e9 | ||
|
|
b0c082d728 | ||
|
|
9640e864a6 | ||
|
|
e1bbb064a1 | ||
|
|
d38ebaeb23 | ||
|
|
39a16260a7 | ||
|
|
2c49a52a41 | ||
|
|
c414a45825 | ||
|
|
e2d6f281d5 | ||
|
|
ba404ffb0b | ||
|
|
af10705632 | ||
|
|
5443363de4 | ||
|
|
e3f7426af4 | ||
|
|
8b907d5f5f | ||
|
|
771190202f | ||
|
|
5a4e3ede2a | ||
|
|
78b350bbc5 | ||
|
|
fe2f0f7489 | ||
|
|
9f20258d5d | ||
|
|
63dd3d4682 | ||
|
|
b1166211e2 | ||
|
|
7d43545303 | ||
|
|
6fa853b309 | ||
|
|
88c7eaed06 | ||
|
|
c730cbc629 | ||
|
|
4ef3fc501b | ||
|
|
c22fd3e73d | ||
|
|
78eb9d6176 | ||
|
|
00f4ba0eeb | ||
|
|
588f64c760 | ||
|
|
6039464342 | ||
|
|
866ab30400 | ||
|
|
57fd6f0604 | ||
|
|
49e83b0c4d | ||
|
|
1cfe4962aa | ||
|
|
79b1da130b | ||
|
|
e128bfcd10 | ||
|
|
e3d3e604f2 | ||
|
|
619a8888eb | ||
|
|
c304d37cbd | ||
|
|
149e0839b1 | ||
|
|
0c1d55b6dc | ||
|
|
d0a79c6a13 | ||
|
|
c6601769ad | ||
|
|
a78ca7eb8d | ||
|
|
59239d2f61 | ||
|
|
bf65ddbff0 | ||
|
|
7e56f3d392 | ||
|
|
4124a568fd | ||
|
|
db7202578d | ||
|
|
e38fa1cdd4 | ||
|
|
a1b2a62e6b |
71
.github/workflows/nodejs.yml
vendored
71
.github/workflows/nodejs.yml
vendored
@@ -6,29 +6,35 @@ on:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
|
||||
test-node:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
node-version: [8.x, 10.x, 12.x, 13.x]
|
||||
node-version: [8.x, 10.x, 12.x, 13.x ]
|
||||
|
||||
steps:
|
||||
- name: Use Node.js ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- run: npm ci
|
||||
- run: npm run bootstrap
|
||||
- run: npm run build-all
|
||||
- run: npm run test-node
|
||||
|
||||
|
||||
test-browser:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
module: [ 'esm', 'umd' ]
|
||||
|
||||
@@ -36,8 +42,67 @@ jobs:
|
||||
- uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: 12.x
|
||||
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- run: npm ci
|
||||
- run: npm run bootstrap
|
||||
- run: npm run build-all
|
||||
- run: npm run test-browser-${{ matrix.module }}
|
||||
|
||||
|
||||
test-react-native:
|
||||
|
||||
runs-on: macos-latest
|
||||
|
||||
# Temporary for testing CI
|
||||
continue-on-error: true
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
|
||||
steps:
|
||||
- name: Use Node.js 12.x
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: 12.x
|
||||
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- run: npm ci
|
||||
- run: npm run build-all
|
||||
- run: npm run test-react
|
||||
|
||||
|
||||
coverage:
|
||||
|
||||
name: Coverage
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
continue-on-error: true
|
||||
|
||||
steps:
|
||||
- uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: 12.x
|
||||
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- run: npm ci
|
||||
- run: npm run build-all
|
||||
- run: npm run test-coverage
|
||||
|
||||
- name: Upload coverage summary
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: coverage-summary
|
||||
path: ./output/summary.txt
|
||||
|
||||
- name: Tar files
|
||||
run: tar -cvf ./output/coverage.tar ./output/lcov-report/
|
||||
|
||||
- name: Upload coverage
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: coverage-complete
|
||||
path: ./output/coverage.tar
|
||||
|
||||
4
.gitignore
vendored
4
.gitignore
vendored
@@ -18,3 +18,7 @@ lerna-debug.log
|
||||
packages/*/tsconfig.tsbuildinfo
|
||||
|
||||
packages/testcases/input/nameprep/**
|
||||
|
||||
.nyc_output/**
|
||||
|
||||
output/**
|
||||
|
||||
55
CHANGELOG.md
55
CHANGELOG.md
@@ -3,6 +3,61 @@ Changelog
|
||||
|
||||
This change log is managed by `scripts/cmds/update-versions` but may be manually updated.
|
||||
|
||||
ethers/v5.0.10 (2020-09-05 01:21)
|
||||
---------------------------------
|
||||
|
||||
- Added retry logic to provider tests. ([0558bba](https://github.com/ethers-io/ethers.js/commit/0558bba8eb1b783ef50bb37bcf4c9bae1f86f1e1), [35b64b9](https://github.com/ethers-io/ethers.js/commit/35b64b9a65e2c09ecb63b0eca712b45a3092c204), [681f2a5](https://github.com/ethers-io/ethers.js/commit/681f2a50b26d7954795dba5aec55bede4740e494))
|
||||
- Fixed link in docs. ([#1028](https://github.com/ethers-io/ethers.js/issues/1028); [2359a98](https://github.com/ethers-io/ethers.js/commit/2359a98641d99b26cf88ec892e3601a8a2c81c9c))
|
||||
- Added memory-like support and new opcodes to asm. ([6fd3bb6](https://github.com/ethers-io/ethers.js/commit/6fd3bb62d10eab1563dc4ddbd88732b4f484ec7a))
|
||||
- Added basic ENS resolver functions for contenthash, text and multi-coin addresses. ([#1003](https://github.com/ethers-io/ethers.js/issues/1003); [83db8a6](https://github.com/ethers-io/ethers.js/commit/83db8a6bd1364458dcfeea544de707df41890b4e))
|
||||
- Added support for changing Reporter logging function. ([d01d0c8](https://github.com/ethers-io/ethers.js/commit/d01d0c8448df40de52253f9e92889ab7e75c6a97))
|
||||
- Initial React Native test harness. ([#993](https://github.com/ethers-io/ethers.js/issues/993); [57eb5b7](https://github.com/ethers-io/ethers.js/commit/57eb5b777e2c67f1f8d74e41d3413e9f0564528d), [d3b473e](https://github.com/ethers-io/ethers.js/commit/d3b473e7c738fdfc65b6f1c8f80bcdacf9827d8a))
|
||||
- Updating shims for constrained environments. ([#944](https://github.com/ethers-io/ethers.js/issues/944), [#993](https://github.com/ethers-io/ethers.js/issues/993); [8abdbbb](https://github.com/ethers-io/ethers.js/commit/8abdbbbf633f96fde2346c4ae70e538895fd7829), [240aac5](https://github.com/ethers-io/ethers.js/commit/240aac568303deff14cbb2366b94c8c89cacefc1))
|
||||
|
||||
ethers/v5.0.9 (2020-08-25 01:45)
|
||||
--------------------------------
|
||||
|
||||
- Updated docs for all packages on npm pages. ([#1013](https://github.com/ethers-io/ethers.js/issues/1013); [cb8f4a3](https://github.com/ethers-io/ethers.js/commit/cb8f4a3a4e378a749c6bbbddf46d8d79d35722cc))
|
||||
- Added JSON support to BigNumber. ([#1010](https://github.com/ethers-io/ethers.js/issues/1010); [8facc1a](https://github.com/ethers-io/ethers.js/commit/8facc1a5305b1f699aa3afc5a0a692abe7927652))
|
||||
- Updated packages for security audit. ([5b5904e](https://github.com/ethers-io/ethers.js/commit/5b5904ea9977ecf8c079a57593b627553f0126a0))
|
||||
- Fix emitted error for ABI code array count mismatch. ([#1004](https://github.com/ethers-io/ethers.js/issues/1004); [b0c082d](https://github.com/ethers-io/ethers.js/commit/b0c082d728dc66b0f2a5ec315da44d6295716284))
|
||||
|
||||
ethers/v5.0.8 (2020-08-04 20:55)
|
||||
--------------------------------
|
||||
|
||||
- Abstract fetchJson for data. ([e2d6f28](https://github.com/ethers-io/ethers.js/commit/e2d6f281d5a2bd749bc72549a4e55f2c752a7bd8), [2c49a52](https://github.com/ethers-io/ethers.js/commit/2c49a52a41a30ae844376561de95f0c851d19f73), [e1bbb06](https://github.com/ethers-io/ethers.js/commit/e1bbb064a10d0b4bf5563e0a79396665d83935a1))
|
||||
|
||||
ethers/v5.0.7 (2020-07-20 02:22)
|
||||
--------------------------------
|
||||
|
||||
- Fix Logger setLogLevel with enum case mismatch. ([#947](https://github.com/ethers-io/ethers.js/issues/947); [5443363](https://github.com/ethers-io/ethers.js/commit/5443363de43e92de712e72d55165c3f4d7f652e9), [af10705](https://github.com/ethers-io/ethers.js/commit/af10705632bc1f8203ea50ea7ed3120b01c67122))
|
||||
- Removed UUID dependency from json-wallets. ([#966](https://github.com/ethers-io/ethers.js/issues/966); [e3f7426](https://github.com/ethers-io/ethers.js/commit/e3f7426af4d6d7e43db322700d768216b06433e0))
|
||||
- Removed unnecessary dependency from BigNumber. ([#951](https://github.com/ethers-io/ethers.js/issues/951); [78b350b](https://github.com/ethers-io/ethers.js/commit/78b350bbc5ea73561bf47038743b9e51049496f7))
|
||||
|
||||
ethers/v5.0.6 (2020-07-16 05:54)
|
||||
--------------------------------
|
||||
|
||||
- Removed unnecessary dependency from BigNumber. ([#951](https://github.com/ethers-io/ethers.js/issues/951); [78b350b](https://github.com/ethers-io/ethers.js/commit/78b350bbc5ea73561bf47038743b9e51049496f7))
|
||||
- Longer Etherscan throttle slot interval. ([9f20258](https://github.com/ethers-io/ethers.js/commit/9f20258d5d39cd901d2078275323071eb0f3505b))
|
||||
- Fixed ENS overrides for the default provider. ([#959](https://github.com/ethers-io/ethers.js/issues/959); [63dd3d4](https://github.com/ethers-io/ethers.js/commit/63dd3d4682b564445948988243fa9139c598587b))
|
||||
- Added Retry-After support and adjustable slot interval to fetchJson. ([7d43545](https://github.com/ethers-io/ethers.js/commit/7d435453039f009b339d835ddee47e35a843711b))
|
||||
- Added initial throttling support. ([#139](https://github.com/ethers-io/ethers.js/issues/139), [#904](https://github.com/ethers-io/ethers.js/issues/904), [#926](https://github.com/ethers-io/ethers.js/issues/926); [88c7eae](https://github.com/ethers-io/ethers.js/commit/88c7eaed061ae9a6798733a97e4e87011d36b8e7))
|
||||
- Use status code 1000 on WebSocket hangup for compatibility. ([588f64c](https://github.com/ethers-io/ethers.js/commit/588f64c760ee49bfb5109bfbaafb4beafe41c52a))
|
||||
- Updated WebSocketProvider to use web-style event listener API. ([57fd6f0](https://github.com/ethers-io/ethers.js/commit/57fd6f06047a1a2a3a46fe8b23ff585293a40062))
|
||||
- Normalize formatUnits to simplified decimals. ([79b1da1](https://github.com/ethers-io/ethers.js/commit/79b1da130be50df80c7e5aeb221edc5669fc211e))
|
||||
- Prevent zero-padding on Solidity type lengths. ([e128bfc](https://github.com/ethers-io/ethers.js/commit/e128bfcd10e006c920532151598700ca33a2127e))
|
||||
- Set sensible defaults for INFURA and AlchemyAPI getWebSocketProvider methods. ([e3d3e60](https://github.com/ethers-io/ethers.js/commit/e3d3e604f299edbafe7d0721c0a3eff5f67c83f4))
|
||||
- Added logger assert methods. ([619a888](https://github.com/ethers-io/ethers.js/commit/619a8888ebe08de9956f60c16703fb3543aeacc4))
|
||||
- Added initial code coverage testing. ([0c1d55b](https://github.com/ethers-io/ethers.js/commit/0c1d55b6dc9c725c86e849d13b911c8bace9821d))
|
||||
- Added destroy to WebSocketProvider. ([d0a79c6](https://github.com/ethers-io/ethers.js/commit/d0a79c6a1362e12f6f102e4af99adfef930092db))
|
||||
- Updated packages (security updates). ([c660176](https://github.com/ethers-io/ethers.js/commit/c6601769ada64832b1ce392680a30cb145c3cab9))
|
||||
|
||||
ethers/v5.0.5 (2020-07-07 23:18)
|
||||
--------------------------------
|
||||
|
||||
- Fixed splitSignature when recoveryParam is encoded directly. ([#893](https://github.com/ethers-io/ethers.js/issues/893), [#933](https://github.com/ethers-io/ethers.js/issues/933); [bf65ddb](https://github.com/ethers-io/ethers.js/commit/bf65ddbff0036f6eb8e99c145f30edff157687f5))
|
||||
- Fixed BigNumber string validation. ([#935](https://github.com/ethers-io/ethers.js/issues/935); [7e56f3d](https://github.com/ethers-io/ethers.js/commit/7e56f3d392e52815c5c859772b99660e0fc38ef5))
|
||||
|
||||
ethers/v5.0.4 (2020-07-04 23:46)
|
||||
--------------------------------
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ A complete Ethereum wallet implementation and utilities in JavaScript (and TypeS
|
||||
- **Tiny** (~104kb compressed; 322kb uncompressed)
|
||||
- **Modular** packages; include only what you need
|
||||
- **Complete** functionality for all your Ethereum desires
|
||||
- Extensive [documentation](https://docs.ethers.io/ethers.js/html/)
|
||||
- Extensive [documentation](https://docs.ethers.io/v5/)
|
||||
- Large collection of **test cases** which are maintained and added to
|
||||
- Fully **TypeScript** ready, with definition files and full TypeScript source
|
||||
- **MIT License** (including ALL dependencies); completely open source to do with as you please
|
||||
@@ -66,7 +66,7 @@ Browse the [documentation](https://docs.ethers.io/v5/) online:
|
||||
- [Full API Documentation](https://docs.ethers.io/v5/api/)
|
||||
- [Various Ethereum Articles](https://blog.ricmoo.com/)
|
||||
|
||||
Or browse the entire documentation as a [single page](https://docs.ethers.io/single-page/) to make searching easier.
|
||||
Or browse the entire documentation as a [single page](https://docs.ethers.io/v5/single-page/) to make searching easier.
|
||||
|
||||
|
||||
Ancillary Packages
|
||||
@@ -75,7 +75,7 @@ Ancillary Packages
|
||||
These are a number of packages not included in the umbrella `ethers` npm package, and
|
||||
additional packages are always being added. Often these packages are for specific
|
||||
use-cases, so rather than adding them to the umbrella package, they are added as
|
||||
ancillary packaged, which can be included by those who need them, while not bloating
|
||||
ancillary packages, which can be included by those who need them, while not bloating
|
||||
everyone else with packages they do not need.
|
||||
|
||||
We will keep a list of useful packages here.
|
||||
|
||||
15
admin/cmds/npm-skip-node8.js
Normal file
15
admin/cmds/npm-skip-node8.js
Normal file
@@ -0,0 +1,15 @@
|
||||
"use strict";
|
||||
|
||||
const { major } = require("semver");
|
||||
|
||||
// This should be used like `node npm-skip-node8 || COMMAND`.
|
||||
// - If node 8, this script returns true, skipping COMMAND
|
||||
// - Otherwise, return false, running COMMAND
|
||||
|
||||
if (major(process.version) > 8) {
|
||||
// Node >8; return "false" (wrt to shell scripting)
|
||||
process.exit(1);
|
||||
} else {
|
||||
// Node 8; return "true" (wrt to shell scripting)
|
||||
process.exit(0);
|
||||
}
|
||||
@@ -1,5 +1,10 @@
|
||||
"use strict";
|
||||
|
||||
const { basename, resolve } = require("path");
|
||||
const fs = require("fs");
|
||||
|
||||
const AWS = require('aws-sdk');
|
||||
|
||||
const config = require("../config");
|
||||
|
||||
const { ChangelogPath, latestChange } = require("../changelog");
|
||||
@@ -33,6 +38,45 @@ if (process.argv.length > 2) {
|
||||
dirnames = dirnames.filter((dirname) => (filter.indexOf(dirname) >= 0));
|
||||
}
|
||||
|
||||
|
||||
function putObject(s3, info) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
s3.putObject(info, function(error, data) {
|
||||
if (error) {
|
||||
reject(error);
|
||||
} else {
|
||||
resolve({
|
||||
name: info.Key,
|
||||
hash: data.ETag.replace(/"/g, '')
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function invalidate(cloudfront, distributionId) {
|
||||
return new Promise((resolve, reject) => {
|
||||
cloudfront.createInvalidation({
|
||||
DistributionId: distributionId,
|
||||
InvalidationBatch: {
|
||||
CallerReference: `${ USER_AGENT }-${ parseInt(((new Date()).getTime()) / 1000) }`,
|
||||
Paths: {
|
||||
Quantity: "1",
|
||||
Items: [
|
||||
"/\*"
|
||||
]
|
||||
}
|
||||
}
|
||||
}, function(error, data) {
|
||||
if (error) {
|
||||
console.log(error);
|
||||
return;
|
||||
}
|
||||
resolve(data.Invalidation.Id);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
(async function() {
|
||||
let token = null;
|
||||
|
||||
@@ -98,27 +142,69 @@ if (process.argv.length > 2) {
|
||||
// Publish the GitHub release
|
||||
const beta = false;
|
||||
if (includeEthers) {
|
||||
|
||||
// Get the latest change from the changelog
|
||||
const change = latestChange();
|
||||
|
||||
// Publish the release to GitHub
|
||||
{
|
||||
// The password above already succeeded
|
||||
const username = await config.get("github-user");
|
||||
const password = await config.get("github-release");
|
||||
|
||||
// Get the latest change from the changelog
|
||||
const change = latestChange();
|
||||
|
||||
// Publish the release
|
||||
const link = await createRelease(username, password, change.version, change.title, change.content, beta, gitCommit);
|
||||
log(`<bold:Published Release:> ${ link }`);
|
||||
}
|
||||
|
||||
/*
|
||||
// Upload the scripts to the CDN and refresh the edge caches
|
||||
{
|
||||
const accessKey = await config.get("aws-upload-scripts-accesskey");
|
||||
const secretKey = await config.get("aws-upload-scripts-secretkey");
|
||||
const s3 =
|
||||
}
|
||||
*/
|
||||
const awsAccessId = await config.get("aws-upload-scripts-accesskey");
|
||||
const awsSecretKey = await config.get("aws-upload-scripts-secretkey");
|
||||
const bucketName = await config.get("aws-upload-scripts-bucket");
|
||||
const originRoot = await config.get("aws-upload-scripts-root");
|
||||
const distributionId = await config.get("aws-upload-scripts-distribution-id");
|
||||
|
||||
const s3 = new AWS.S3({
|
||||
apiVersion: '2006-03-01',
|
||||
accessKeyId: awsAccessId,
|
||||
secretAccessKey: awsSecretKey
|
||||
});
|
||||
|
||||
// Upload the libs to ethers-v5.0 and ethers-5.0.x
|
||||
const fileInfos = [
|
||||
{ filename: "packages/ethers/dist/ethers.esm.min.js", key: `ethers-${ change.version.substring(1) }.esm.min.js` },
|
||||
{ filename: "packages/ethers/dist/ethers.umd.min.js", key: `ethers-${ change.version.substring(1) }.umd.min.js` },
|
||||
{ filename: "packages/ethers/dist/ethers.esm.min.js", key: `ethers-5.0.esm.min.js` },
|
||||
{ filename: "packages/ethers/dist/ethers.umd.min.js", key: `ethers-5.0.umd.min.js` },
|
||||
];
|
||||
|
||||
for (let i = 0; i < fileInfos.length; i++) {
|
||||
const fileInfo = fileInfos[i];
|
||||
const status = await putObject(s3, {
|
||||
ACL: 'public-read',
|
||||
Body: fs.readFileSync(resolve(__dirname, "../../", fileInfo.filename)),
|
||||
Bucket: bucketName,
|
||||
ContentType: "application/javascript; charset=utf-8",
|
||||
Key: (originRoot + fileInfo.key)
|
||||
});
|
||||
|
||||
log(`<bold:Uploaded :> https://cdn.ethers.io/lib/${ fileInfo.key }`);
|
||||
}
|
||||
|
||||
// Flush the edge caches
|
||||
{
|
||||
const cloudfront = new AWS.CloudFront({
|
||||
//apiVersion: '2006-03-01',
|
||||
accessKeyId: awsAccessId,
|
||||
secretAccessKey: awsSecretKey
|
||||
});
|
||||
|
||||
const invalidationId = await invalidate(cloudfront, distributionId);
|
||||
log(`<bold:Invalidated Cache :> ${ invalidationId }`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
})();
|
||||
|
||||
@@ -87,7 +87,7 @@ function start(root, options) {
|
||||
});
|
||||
|
||||
server.listen(options.port, () => {
|
||||
console.log(`Listening on port: ${ options.port }`);
|
||||
console.log(`Server running on: http://localhost:${ options.port }`);
|
||||
});
|
||||
|
||||
return server;
|
||||
|
||||
@@ -16,17 +16,17 @@ decrypt decrypted decrypting deployed deploying deprecated detected
|
||||
discontinued earliest email enabled encoded encoding encrypt
|
||||
encrypted encrypting entries euro exceeded existing expected
|
||||
expired failed fetches formatted formatting funding generated
|
||||
has ignoring implemented implementer imported including instantiate
|
||||
keyword labelled larger lookup matches mined modified modifies multi
|
||||
hardened has highly ignoring implemented implementer imported including instantiate
|
||||
joined keyword labelled larger lookup matches mined modified modifies multi
|
||||
named needed nested neutered numeric offline optimizer overriding owned packed
|
||||
padded parsed parsing passed placeholder processing properties reached
|
||||
padded parsed parsing passed placeholder processing properties prototyping reached
|
||||
recommended recovered redacted remaining replaced required
|
||||
serializes shared signed signing skipped stored supported tagging targetted
|
||||
transactions uninstall unstake unsubscribe using verifies website
|
||||
throttled transactions uninstall unstake unsubscribe using verifies website
|
||||
|
||||
// Overly Specific Words
|
||||
BIP BIP39 BIP44 crypto eip hashes hmac icap
|
||||
keccak namehash ripemd RLP scrypt secp sha
|
||||
bech BIP BIP39 BIP44 btc bzz crypto eip etc hashes hmac icap
|
||||
keccak ltc namehash ripemd RLP scrypt secp sha xdai
|
||||
|
||||
blockhash
|
||||
|
||||
@@ -43,14 +43,14 @@ ABIEncoder testcase numberish Wordlist
|
||||
|
||||
// Common Code Strings
|
||||
abi addr api app arg arrayify asm basex bigint bignumber bn byte
|
||||
bytecode callback calldata checksum ciphertext cli codepoint config
|
||||
bytecode callback calldata checksum ciphertext cli codepoint commify config
|
||||
contenthash ctr ctrl debug dd dklen eexist encseed eof ethaddr
|
||||
ethseed ethers eval exec filename func gz hid http https hw iv
|
||||
info init ipc json kdf kdfparams labelhash lang lib mm multihash nfc
|
||||
nfkc nfd nfkd nodehash nullish oob opcode pbkdf pc plugin pragma pre prf
|
||||
nfkc nfd nfkd nodehash notok nullish oob opcode pbkdf pc plugin pragma pre prf
|
||||
repl rpc sighash topichash solc stdin stdout subclasses subnode
|
||||
timeout todo txt ufixed utc utf util url uuid vm vs websocket
|
||||
wikipedia wx xe yyyy zlib
|
||||
wikipedia wx xe xpriv xpub xx yyyy zlib
|
||||
|
||||
// AbiV2
|
||||
abiv
|
||||
@@ -58,9 +58,10 @@ abiv
|
||||
// Query parameters
|
||||
apikey asc endblock startblock
|
||||
|
||||
Cloudflare Etherscan INFURA IPFS MetaMask Nodesmith Trezor ledgerhq
|
||||
axic bitcoinjs browserify easyseed ethereumjs
|
||||
goerli homestead kotti kovan mainnet morden mordor rinkeby ropsten testnet
|
||||
alchemyapi Cloudflare Etherscan INFURA IPFS MetaMask Nodesmith
|
||||
Trezor ledgerhq axic bitcoinjs browserify easyseed ethereumjs
|
||||
goerli homestead kotti kovan mainnet morden mordor rinkeby
|
||||
ropsten testnet
|
||||
|
||||
// Demo words
|
||||
args foo eth foo foobar ll localhost passwd ricmoo tx xxx yna
|
||||
|
||||
103
docs.wrm/api-keys.wrm
Normal file
103
docs.wrm/api-keys.wrm
Normal file
@@ -0,0 +1,103 @@
|
||||
_section: Provider API Keys @<api-keys>
|
||||
|
||||
//( **TL; DR** – sign up for your own API keys with the links below to improve your application performance )//
|
||||
|
||||
When using a [[Provider]] backed by an API service (such as [[link-alchemy]],
|
||||
[[link-etherscan]] or [[link-infura]]), the service requires an API key,
|
||||
which allows each service to track individual projects and their usage and
|
||||
permissions.
|
||||
|
||||
The ethers library offers default API keys for each service, so that each
|
||||
[[Provider]] works out-of-the-box.
|
||||
|
||||
These API keys are a provided as a community resource by the backend services
|
||||
for low-traffic projects and for early prototyping.
|
||||
|
||||
Since these API keys are shared by all users (that have not acquired their
|
||||
own API key), they are aggressively throttled which means reties occur more
|
||||
frequently and the responses are slower.
|
||||
|
||||
It is **highly recommended** that you sign up for a free API key from each service for their
|
||||
free tier, which (depending on the service) includes many advantages:
|
||||
|
||||
- a much **higher request rate** and concurrent request limit
|
||||
- **faster** responses with fewer retries and timeouts
|
||||
- useful **metric tracking** for performance tuning and to analyze your customer behaviour
|
||||
- more **advanced APIs**, such as archive data or advanced log queries
|
||||
|
||||
_subsection: Etherscan @<api-keys--etherscan>
|
||||
|
||||
Etherscan is an Ethereum block explorer, which is possibly the most useful
|
||||
developer tool for building and debugging Ethereum applications.
|
||||
|
||||
They offer an extensive collection of API endpoints which provide all the
|
||||
operations required to interact with the Ethereum Blockchain.
|
||||
|
||||
[Sign up for a free API key on Etherscan](link-etherscan-signup)
|
||||
|
||||
**Benefits:**
|
||||
|
||||
- higher rate limit (since you are not using the [shared rate limit](link-etherscan-ratelimit))
|
||||
- customer usage metrics
|
||||
|
||||
_subsection: INFURA @<api-keys--infura>
|
||||
|
||||
The INFURA service has been around for quite some time and is very robust
|
||||
and reliable and highly recommend.
|
||||
|
||||
They offer a standard JSON-RPC interface and a WebSocket interface, which makes
|
||||
interaction with standard tools versatile, simple and straight forward.
|
||||
|
||||
[Sign up for a free Project ID on INFURA](link-infura-signup)
|
||||
|
||||
**Benefits:**
|
||||
|
||||
- higher rate limit
|
||||
- customer usage metrics
|
||||
- access to archive data (requires paid upgrade)
|
||||
|
||||
_subsection: Alchemy @<api-keys--alchemy>
|
||||
|
||||
The Alchemy service has been around a few years and is also very robust
|
||||
and reliable.
|
||||
|
||||
They offer a standard JSON-RPC interface and a WebSocket interface, as well
|
||||
as a collection of advanced APIs for interacting with tokens and to assist
|
||||
with debugging.
|
||||
|
||||
[Sign up for a free API key on Alchemy](link-alchemy-signup)
|
||||
|
||||
**Benefits:**
|
||||
|
||||
- higher rate limit
|
||||
- customer usage metrics
|
||||
- access to advanced token balance and metadata APIs
|
||||
- access to advanced debugging trace and revert reason APIs
|
||||
|
||||
|
||||
_subsection: Creating a Default Provider @<api-keys--getDefaultProvider>
|
||||
|
||||
The [default provider](providers-getDefaultProvider) connects to multiple
|
||||
backends and verifies their results internally, making it simple to have
|
||||
a high level of trust in third-party services.
|
||||
|
||||
A second optional parameter allows API keys to be specified to each
|
||||
Provider created internally and any API key omitted will fallback onto
|
||||
using the default API key for that service.
|
||||
|
||||
It is **highly recommended** that you provide an API for each service, to
|
||||
maximize your applications performance.
|
||||
|
||||
_code: Passing API Keys into getDefaultProvider @lang<script>
|
||||
|
||||
// Use the mainnet
|
||||
const network = "homestead";
|
||||
|
||||
// Specify your own API keys
|
||||
// Each is optional, and if you omit it the default
|
||||
// API key for that service will be used.
|
||||
const provider = ethers.getDefaultProvider(network, {
|
||||
etherscan: YOUR_ETHERSCAN_API_KEY,
|
||||
infura: YOUR_INFURA_PROJECT_ID,
|
||||
alchemy: YOUR_ALCHEMY_API_KEY
|
||||
});
|
||||
@@ -178,7 +178,7 @@ _subsection: Meta-Class Filters @NOTE<(added at Runtime)>
|
||||
Since the Contract is a Meta-Class, the methods available here depend
|
||||
on the ABI which was passed into the **Contract**.
|
||||
|
||||
_property: erc20.filters.Transafer([ fromAddress [ , toAddress ] ]) => Filter
|
||||
_property: erc20.filters.Transfer([ fromAddress [ , toAddress ] ]) => Filter
|
||||
Returns a new Filter which can be used to [query](erc20-queryfilter) or
|
||||
to [subscribe/unsubscribe to events](erc20-events).
|
||||
|
||||
|
||||
@@ -4,9 +4,9 @@ An Application Programming Interface (API) is the formal
|
||||
specification of the library.
|
||||
|
||||
_toc:
|
||||
contract
|
||||
signer
|
||||
providers
|
||||
signer
|
||||
contract
|
||||
utils
|
||||
other
|
||||
experimental
|
||||
|
||||
@@ -145,9 +145,7 @@ provider = new InfuraProvider("homestead", {
|
||||
// Connect to the INFURA WebSocket endpoints with a WebSocketProvider
|
||||
provider = InfuraProvider.getWebSocketProvider()
|
||||
// <hide>
|
||||
provider._websocket.onopen = function(){
|
||||
provider._websocket.close();
|
||||
};
|
||||
provider.destroy();
|
||||
// </hide>
|
||||
|
||||
|
||||
@@ -196,6 +194,12 @@ provider = new AlchemyProvider("ropsten");
|
||||
provider = new AlchemyProvider(null, apiKey);
|
||||
provider = new AlchemyProvider("homestead", apiKey);
|
||||
|
||||
// Connect to the Alchemy WebSocket endpoints with a WebSocketProvider
|
||||
provider = AlchemyProvider.getWebSocketProvider()
|
||||
// <hide>
|
||||
provider.destroy();
|
||||
// </hide>
|
||||
|
||||
|
||||
_subsection: CloudflareProvider @<CloudflareProvider> @inherit<[[UrlJsonRpcProvider]]> @src<providers:class.CloudflareProvider>
|
||||
|
||||
|
||||
@@ -282,7 +282,7 @@ provider.once(txHash, (transaction) => {
|
||||
filter = {
|
||||
address: "dai.tokens.ethers.eth",
|
||||
topics: [
|
||||
utils.id("Transfer(address,address,uint256")
|
||||
utils.id("Transfer(address,address,uint256)")
|
||||
]
|
||||
}
|
||||
provider.on(filter, (log, event) => {
|
||||
@@ -293,7 +293,7 @@ provider.on(filter, (log, event) => {
|
||||
// Notice this is an array of topic-sets and is identical to
|
||||
// using a filter with no address (i.e. match any address)
|
||||
topicSets = [
|
||||
utils.id("Transfer(address,address,uint256"),
|
||||
utils.id("Transfer(address,address,uint256)"),
|
||||
null,
|
||||
[
|
||||
myAddress,
|
||||
|
||||
@@ -181,12 +181,18 @@ module.exports = {
|
||||
"link-infura": { name: "INFURA", url: "https:/\/infura.io" },
|
||||
"link-ledger": "https:/\/www.ledger.com",
|
||||
"link-metamask": { name: "Metamask", url: "https:/\/metamask.io/" },
|
||||
"link-otto": "https:/\/github.com/robertkrimen/otto",
|
||||
"link-parity": { name: "Parity", url: "https:/\/www.parity.io" },
|
||||
"link-rtd": "https:/\/github.com/readthedocs/sphinx_rtd_theme",
|
||||
"link-semver": { name: "semver", url: "https:/\/semver.org" },
|
||||
"link-solidity": { name: "Solidity" , url: "https:/\/solidity.readthedocs.io/en/v0.6.2/" },
|
||||
"link-sphinx": { name: "Sphinx", url: "https:/\/www.sphinx-doc.org/" },
|
||||
|
||||
"link-alchemy-signup": "https:/\/alchemyapi.io/signup",
|
||||
"link-etherscan-signup": "https:/\/etherscan.io/apis",
|
||||
"link-etherscan-ratelimit": "https:/\/info.etherscan.com/api-return-errors/",
|
||||
"link-infura-signup": "https:/\/infura.io/register",
|
||||
|
||||
"link-json-rpc": "https:/\/github.com/ethereum/wiki/wiki/JSON-RPC",
|
||||
"link-web3-send": "https:/\/github.com/ethereum/web3.js/blob/1.x/packages/web3-providers-http/types/index.d.ts#L57",
|
||||
"link-parity-trace": "https:/\/openethereum.github.io/wiki/JSONRPC-trace-module",
|
||||
@@ -197,6 +203,11 @@ module.exports = {
|
||||
"link-legacy-docs3": "https:/\/docs.ethers.io/v3/",
|
||||
"link-legacy-docs4": "https:/\/docs.ethers.io/v4/",
|
||||
|
||||
"link-github-ci": "https:/\/github.com/ethers-io/ethers.js/actions/runs/158006903",
|
||||
"link-github-issues": "https:/\/github.com/ethers-io/ethers.js/issues",
|
||||
|
||||
"link-issue-407": "https:/\/github.com/ethers-io/ethers.js/issues/407",
|
||||
|
||||
"link-infura-secret": "https:/\/infura.io/docs/gettingStarted/authentication",
|
||||
|
||||
"link-web3": "https:/\/github.com/ethereum/web3.js",
|
||||
@@ -237,6 +248,7 @@ module.exports = {
|
||||
"link-js-bigint": "https:/\/developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt",
|
||||
"link-js-normalize": { name: "String.normalize", url: "https:/\/developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize" },
|
||||
"link-js-maxsafe": "https:/\/developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER#Description",
|
||||
"link-js-proxy": "https:/\/developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy",
|
||||
"link-js-typedarray": "https:/\/developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray",
|
||||
|
||||
"link-ricmoo-humanreadableabi": "https:/\/blog.ricmoo.com/human-readable-contract-abis-in-ethers-js-141902f4d917",
|
||||
|
||||
@@ -38,6 +38,7 @@ _toc:
|
||||
|
||||
getting-started
|
||||
concepts
|
||||
api-keys
|
||||
api
|
||||
cli
|
||||
cookbook
|
||||
|
||||
@@ -1,5 +1,16 @@
|
||||
_section: Migration: From Ethers v4 @<migration-v4>
|
||||
|
||||
This document only covers the features present in v4 which have changed
|
||||
in some important way in v5.
|
||||
|
||||
It does not cover all the new additional featuers that have been added and
|
||||
mainly aims to help those updating their older scripts and applications to
|
||||
retain functional parity.
|
||||
|
||||
If you encounter any missing changes, please let me know and I'll update this
|
||||
guide.
|
||||
|
||||
|
||||
_subsection: BigNumber
|
||||
|
||||
_heading: Namespace
|
||||
@@ -18,6 +29,7 @@ ethers.BigNumberish
|
||||
|
||||
|
||||
_heading: Creating Instances
|
||||
|
||||
The ``bigNumberify`` method was always preferred over the constructor
|
||||
since it could short-circuit an object instantiation for [[BigNumber]
|
||||
objects (since they are immutable). This has been moved to a static
|
||||
@@ -37,9 +49,99 @@ ethers.BigNumber.from(someValue)
|
||||
|
||||
_subsection: Contracts
|
||||
|
||||
_code: @lang<script>
|
||||
_heading: ENS Name Resolution
|
||||
|
||||
// @TODO
|
||||
The name of the resolved address has changed. If the address passed into the
|
||||
constructor was an ENS name, the address will be resovled before any calls
|
||||
are made to the contract.
|
||||
|
||||
The name of the property where the resolved address has changed from ``addressPromise``
|
||||
to ``resolvedAddress``.
|
||||
|
||||
_code: Resolved ENS Names @lang<script>
|
||||
|
||||
// v4
|
||||
contract.addressPromise
|
||||
|
||||
// v5
|
||||
contract.resolvedAddress
|
||||
|
||||
|
||||
_heading: Gas Estimation
|
||||
|
||||
The only difference in gas estimation is that the bucket has changed
|
||||
its name from ``estimate`` to ``estimateGas``.
|
||||
|
||||
_code: Gas Estimation @lang<script>
|
||||
|
||||
// v4
|
||||
contract.estimate.transfer(toAddress, amount)
|
||||
|
||||
// v5
|
||||
contract.estimateGas.transfer(toAddress, amount)
|
||||
|
||||
_heading: Functions
|
||||
|
||||
In a contract in ethers, there is a ``functions`` bucket, which exposes
|
||||
all the methods of a contract.
|
||||
|
||||
All these functions are available on the root contract itself as well
|
||||
and historically there was no difference between ``contact.foo`` and
|
||||
``contract.functions.foo``. The original reason for the ``functions`` bucket
|
||||
was to help when there were method names that collided with other buckets,
|
||||
which is rare.
|
||||
|
||||
In v5, the ``functions`` bucket is now intended to help with frameworks and
|
||||
for the new error recovery API, so most users should use the methods on the
|
||||
root contract.
|
||||
|
||||
The main difference will occur when a contract method only returns a single
|
||||
item. The root method will dereference this automatically while the ``functions``
|
||||
bucket will preserve it as an [[Result]].
|
||||
|
||||
If a method returns multiple items, there is no difference.
|
||||
|
||||
This helps when creating a framework, since the result will always be known to
|
||||
have the same number of components as the [[Fragment]] outputs, without having
|
||||
to handle the special case of a single return value.
|
||||
|
||||
_code: Functions Bucket @lang<script>
|
||||
|
||||
const abi = [
|
||||
|
||||
// Returns a single value
|
||||
"function single() view returns (uint8)",
|
||||
|
||||
// Returns two values
|
||||
"function double() view returns (uint8, uint8)",
|
||||
];
|
||||
|
||||
// v4
|
||||
await contract.single()
|
||||
// 123
|
||||
await contract.functions.single()
|
||||
// 123
|
||||
|
||||
|
||||
// v5 (notice the change in the .function variant)
|
||||
await contract.single()
|
||||
// 123
|
||||
await contract.functions.single()
|
||||
// [ 123 ]
|
||||
|
||||
|
||||
// v4
|
||||
await contract.double()
|
||||
// [ 123, 5 ]
|
||||
await contract.functions.double()
|
||||
// [ 123, 5 ]
|
||||
|
||||
|
||||
// v5 (no difference from v4)
|
||||
await contract.double()
|
||||
// [ 123, 5 ]
|
||||
await contract.functions.double()
|
||||
// [ 123, 5 ]
|
||||
|
||||
|
||||
_subsection: Errors
|
||||
@@ -84,6 +186,7 @@ logger.info(...)
|
||||
|
||||
|
||||
_subsection: Interface
|
||||
|
||||
The [[Interface]] object has undergone the most dramatic changes.
|
||||
|
||||
It is no longer a meta-class and now has methods that simplify handling
|
||||
@@ -178,14 +281,6 @@ const eventSig = eventFragment.format()
|
||||
const topic = interface.getTopic(eventFragment)
|
||||
|
||||
|
||||
_subsection: Utilities
|
||||
|
||||
_heading: Renaming
|
||||
|
||||
_code: @lang<script>
|
||||
|
||||
// @TODO
|
||||
|
||||
_subsection: Wallet
|
||||
|
||||
_heading: Mnemonic Phrases
|
||||
|
||||
@@ -1,13 +1,198 @@
|
||||
_section: Migration: From Web3.js
|
||||
|
||||
TODO
|
||||
|
||||
_subsection: Contracts
|
||||
This migration guide focuses on migrating web3.js version 1.2.9 to ethers.js v5.
|
||||
|
||||
_subsection: Providers
|
||||
|
||||
In ethers, a provider provides an abstraction for a connection to the Ethereum Network. It can be used to issue read only queries and send signed state changing transactions to the Ethereum Network.
|
||||
|
||||
_heading: Connecting to Ethereum
|
||||
|
||||
_code: @lang<script>
|
||||
|
||||
// web3
|
||||
var Web3 = require('web3');
|
||||
var web3 = new Web3('http://localhost:8545');
|
||||
|
||||
// ethers
|
||||
var ethers = require('ethers');
|
||||
const url = "http://127.0.0.1:8545";
|
||||
const provider = new ethers.providers.JsonRpcProvider(url);
|
||||
|
||||
|
||||
_heading: Connecting to Ethereum: Metamask
|
||||
|
||||
|
||||
_code: @lang<script>
|
||||
|
||||
// web3
|
||||
const web3 = new Web3(Web3.givenProvider);
|
||||
|
||||
// ethers
|
||||
const provider = new ethers.providers.Web3Provider(window.ethereum);
|
||||
|
||||
|
||||
_subsection: Signers
|
||||
|
||||
In ethers, a **signer** is an abstraction of an Ethereum Account. It can be used to sign messages and transactions and send signed transactions to the Ethereum Network.
|
||||
|
||||
In web3, an account can be used to sign messages and transactions.
|
||||
|
||||
|
||||
_heading: Creating signer
|
||||
|
||||
_code: @lang<script>
|
||||
|
||||
// web3
|
||||
const account = web3.eth.accounts.create();
|
||||
|
||||
// ethers (create random new account)
|
||||
const signer = ethers.Wallet.createRandom();
|
||||
|
||||
// ethers (connect to JSON-RPC accounts)
|
||||
const signer = provider.getSigner();
|
||||
|
||||
|
||||
_heading: Signing a message
|
||||
|
||||
_code: @lang<script>
|
||||
|
||||
// web3 (using a private key)
|
||||
signature = web3.eth.accounts.sign('Some data', privateKey)
|
||||
|
||||
// web3 (using a JSON-RPC account)
|
||||
// @TODO
|
||||
|
||||
// ethers
|
||||
signature = await signer.signMessage('Some data')
|
||||
|
||||
|
||||
_subsection: Contracts
|
||||
|
||||
A contract object is an abstraction of a smart contract on the Ethereum Network. It allows for easy interaction with the smart contact.
|
||||
|
||||
_heading: Deploying a Contract
|
||||
|
||||
_code: @lang<script>
|
||||
|
||||
// web3
|
||||
const contract = new web3.eth.Contract(abi);
|
||||
contract.deploy({
|
||||
data: bytecode,
|
||||
arguments: ["my string"]
|
||||
})
|
||||
.send({
|
||||
from: "0x12598d2Fd88B420ED571beFDA8dD112624B5E730",
|
||||
gas: 150000,
|
||||
gasPrice: "30000000000000"
|
||||
}), function(error, transactionHash){ ... })
|
||||
.then(function(newContract){
|
||||
console.log('new contract', newContract.options.address)
|
||||
});
|
||||
|
||||
// ethers
|
||||
const signer = provider.getSigner();
|
||||
const factory = new ethers.ContractFactory(abi, bytecode, signer);
|
||||
const contract = await factory.deploy("hello world");
|
||||
console.log('contract address', contract.address);
|
||||
|
||||
// wait for contract creation transaction to be mined
|
||||
await contract.deployTransaction.wait();
|
||||
|
||||
|
||||
_heading: Interacting with a Contract
|
||||
|
||||
_code: @lang<script>
|
||||
|
||||
// web3
|
||||
const contract = new web3.eth.Contract(abi, contractAddress);
|
||||
// read only query
|
||||
contract.methods.getValue().call();
|
||||
// state changing operation
|
||||
contract.methods.changeValue(42).send({from: ....})
|
||||
.on('receipt', function(){
|
||||
...
|
||||
});
|
||||
|
||||
// ethers
|
||||
// pass a provider when initiating a contract for read only queries
|
||||
const contract = new ethers.Contract(contractAddress, abi, provider);
|
||||
const value = await contract.getValue();
|
||||
|
||||
|
||||
// pass a signer to create a contract instance for state changing operations
|
||||
const contract = new ethers.Contract(contractAddress, abi, signer);
|
||||
const tx = await contract.changeValue(33);
|
||||
|
||||
// wait for the transaction to be mined
|
||||
const receipt = await tx.wait();
|
||||
|
||||
|
||||
_heading: Overloaded Functions
|
||||
|
||||
Overloaded functions are functions that have the same name but different parameter
|
||||
types.
|
||||
|
||||
In ethers, the syntax to call an overloaded contract function is different
|
||||
from the non-overloaded function. This section shows the differences between web3
|
||||
and ethers when calling overloaded functions.
|
||||
|
||||
See [issue #407](link-issue-407) for more details.
|
||||
|
||||
_code: @lang<script>
|
||||
|
||||
// web3
|
||||
message = await contract.methods.getMessage('nice').call();
|
||||
|
||||
|
||||
// ethers
|
||||
const abi = [
|
||||
"function getMessage(string) public view returns (string)",
|
||||
"function getMessage() public view returns (string)"
|
||||
]
|
||||
const contract = new ethers.Contract(address, abi, signer);
|
||||
|
||||
// for ambiguous functions (two functions with the same
|
||||
// name), the signature must also be specified
|
||||
message = await contract['getMessage(string)']('nice');
|
||||
|
||||
|
||||
_subsection: Numbers
|
||||
|
||||
_heading: BigNumber
|
||||
|
||||
Convert to BigNumber:
|
||||
|
||||
_code: @lang<script>
|
||||
|
||||
// web3
|
||||
web3.utils.toBN('123456');
|
||||
|
||||
// ethers (from a number; must be within safe range)
|
||||
ethers.BigNumber.from(123456)
|
||||
|
||||
// ethers (from base-10 string)
|
||||
ethers.BigNumber.from("123456")
|
||||
|
||||
// ethers (from hex string)
|
||||
ethers.BigNumber.from("0x1e240")
|
||||
|
||||
|
||||
_subsection: Utilities
|
||||
|
||||
_heading: Hash
|
||||
|
||||
Computing Keccak256 hash of a UTF-8 string in web3 and ethers:
|
||||
|
||||
_code: @lang<script>
|
||||
|
||||
// web3
|
||||
web3.utils.sha3('hello world');
|
||||
web3.utils.keccak256('hello world');
|
||||
|
||||
// ethers (hash of a string)
|
||||
ethers.utils.id('hello world')
|
||||
|
||||
// ethers (hash of binary data)
|
||||
ethers.utils.keccak256('0x4242')
|
||||
|
||||
|
||||
@@ -1,3 +1,385 @@
|
||||
_section: Testing
|
||||
|
||||
Here goes info about testing
|
||||
Testing is a critcial part of any library which wishes to remain secure, safe
|
||||
and reliable.
|
||||
|
||||
Ethers currently has **over 23k tests** among its test suites, which are all
|
||||
made available for other projects to use as simple exported GZIP-JSON files.
|
||||
|
||||
The tests are run on every check-in and the results can been seen on the
|
||||
[GitHub CI Action](link-github-ci).
|
||||
|
||||
We also strive to constantly add new test cases, especially when issues
|
||||
arise to ensure the issue is present prior to the fix, corrected after the
|
||||
fix and included to prevent future changes from causing a regression.
|
||||
|
||||
A large number of the test cases were created procedurally by using
|
||||
known correct implementations from various sources (such as Geth) and
|
||||
written in different languages and verifyied with multiple libraries.
|
||||
|
||||
For example, the ABI test suites were generated by procedurally generating
|
||||
a list of types, for each type choosing a random (valid) value, which then
|
||||
was converted into a Solidity source file, compiled using ``solc`` and
|
||||
deployed to a running Parity node and executed, with its outputs being
|
||||
captured. Similar to the how many of the hashing, event and selector test
|
||||
cases were created.
|
||||
|
||||
|
||||
_subsection: Supported Platforms @<testing-supported>
|
||||
|
||||
While web technologies move quite fast, especially in the Web3 universe, we try
|
||||
to keep ethers as accessible as possible.
|
||||
|
||||
Currently ethers should work on almost any ES3 or better environment and tests
|
||||
are run against:
|
||||
|
||||
- node.js 8.x
|
||||
- node.js 10.x
|
||||
- node.js 12.x
|
||||
- node.js 13.x
|
||||
- Web Browsers (using UMD)
|
||||
- Web Browsers (using ES modules)
|
||||
|
||||
If there is an environment you feel has been overlooked or have suggestions, please feel
|
||||
free to reach out by opening an [issue on Github](link-github-issues).
|
||||
|
||||
We would like to add a test build for Expo and React as those developers often seem
|
||||
to encounter pain points when using ethers, so if you have experience or ideas on this,
|
||||
[bug us](link-github-issues).
|
||||
|
||||
The next Major version (probably summer 2021) will likely drop support for node 8.x
|
||||
and will require ES2015 for [Proxy](link-js-proxy).
|
||||
|
||||
Certain features in JavaScript are also avoided, such as look-behind tokens in regular
|
||||
expressions, since these have caused conflicts (at import time) with certain JavaScript
|
||||
environmants such as [Otto](link-otto).
|
||||
|
||||
Basically, the moral of the story is "be inclusive and don't drop people needlessly".
|
||||
|
||||
|
||||
_subsection: Test Suites @<testing-suites>
|
||||
|
||||
The test suites are avaialble a gzipped JSON files in the
|
||||
``@ethersproject/testcases``, which makes it easy to install and import
|
||||
(both GZIP and JSON are quite easy to consume from most langauges). Each
|
||||
test suite also has its schema available in this package.
|
||||
|
||||
_table: Test Suites @style<full>
|
||||
|
||||
$Account: Private Keys and addresses in checksum and ICAP formats
|
||||
$ContractEvents: Compiled Solidity, ABI interfaces, input types/values with the
|
||||
output types/values for emitted events; all tests were
|
||||
executed against real Ethereum nodes
|
||||
$ContractAbi: Compiled Solidity, ABI interfaces, input types/values with the
|
||||
output types/values, encoded and decoded binrary data and normalized
|
||||
values for function calls executed against real Ethereum nodes.
|
||||
$ContractAbi2: Identical to ``contract-interface``, except with emphasis on
|
||||
the ABIv2 coder which supports nested dynami types and strutured
|
||||
data
|
||||
$ContractSignatures: Contract signatures and matching selectors
|
||||
$Hashes: Data and respective hashes against a variety of hash functions
|
||||
$HDNode: HDNodes (BIP-32) with mnemonics, entropy, seed and computed nodes
|
||||
with pathes and addresses
|
||||
$Namehash: ENS names along with computed [namehashes](link-namehash
|
||||
$Nameprep: IDNA and Nameprep representations including official vectors
|
||||
$RLP: Recursive-Length Prefix (RLP) data and encodings
|
||||
$SoliditiyHashes: Hashes based on the Solidity non-standard packed form
|
||||
$Transactions: Signed and unsigned transactions with their serialized formats
|
||||
including both with and without EIP-155 replay protection
|
||||
$Units: Values converted between various units
|
||||
$Wallet: Keystore JSON format wallets, passwords and decrypted values
|
||||
$Wordlist: Fully decompressed BIP-39 offcial wordlists
|
||||
|
||||
| **Filename** | **Test Cases** <|
|
||||
| accounts.json.gz | $Account <|
|
||||
| contract-events.json.gz | $ContractEvents <|
|
||||
| contract-interface.json.gz | $ContractAbi <|
|
||||
| contract-interface-abi2.json.gz | $ContractAbi2 <|
|
||||
| contract-signatures.json.gz | $ContractSignatures <|
|
||||
| hashes.json.gz | $Hashes <|
|
||||
| hdnode.json.gz | $HDNode <|
|
||||
| namehash.json.gz | $Namehash <|
|
||||
| nameprep.json.gz | $Nameprep <|
|
||||
| rlp-coder.json.gz | $RLP <|
|
||||
| solidity-hashes.json.gz | $SoliditiyHashes <|
|
||||
| transactions.json.gz | $Transactions <|
|
||||
| units.json.gz | $Units <|
|
||||
| wallets.json.gz | $Wallet <|
|
||||
| wordlists.json.gz | $Wordlist <|
|
||||
|
||||
|
||||
_subsection: Test Suite API @<testing-api>
|
||||
|
||||
There are also convenience functions for those developing directly in TypeScript.
|
||||
|
||||
_property: testcases.loadTests(tag) => Array<TestCase>
|
||||
Load all the given testcases for the //tag//.
|
||||
|
||||
A tag is the string in the above list of test case names not including
|
||||
any extenstion (e.g. ``"solidity-hashes"``)
|
||||
|
||||
_property: testcases.TestCase.TEST_NAME
|
||||
Most testcases have its schema available as a TypeScript type to make testing
|
||||
each property easier.
|
||||
|
||||
_heading: Deterministic Random Numbers (DRNG)
|
||||
|
||||
When creating test cases, often we want want random data from the perspective
|
||||
we do not case what values are used, however we want the values to be consistent
|
||||
accross runs. Otherwise it becomes difficult to reproduce an issue.
|
||||
|
||||
In each of the following the seed is used to control the random value returned. Be
|
||||
sure to tweak the seed properly, for eaxmple on each iteration change the value and
|
||||
in recursive functions, concatentate to the seed.
|
||||
|
||||
_property: testcases.randomBytes(seed, lower [, upper ]) => Uint8Array
|
||||
Return at least //lower// random bytes, up to //upper// (exclusive) if specified,
|
||||
given //seed//. If //upper// is omitted, exactly ///lower// bytes are returned.
|
||||
|
||||
_property: testcases.randomHexString(seed, lower [, upper ]) => string<[[DataHexString]]>
|
||||
Identical to randomBytes, except returns the value as a [[DataHexString]] instead of a
|
||||
Uint8Array.
|
||||
|
||||
_property: testcases.randomNumber(seed, lower, upper) => number
|
||||
Returns a random number of at least //lower// and less than //upper//
|
||||
given //seed//.
|
||||
|
||||
|
||||
_subsection: Schemas @<testing-schemas>
|
||||
|
||||
This section is still a work in progress, but will outline some of the more nuanced
|
||||
aspects of the test cases and their values.
|
||||
|
||||
There will likely be an overhaul of the test cases in the next major version, to
|
||||
make code coverage testing more straight forward and to collapse some of the redundancy.
|
||||
|
||||
For example, there is no longer a need to separate the ABI and ABIv2 test case and the
|
||||
accounts and transactions suites can be merged into one large collection.
|
||||
|
||||
|
||||
_heading: Accounts
|
||||
|
||||
Basic account information using a private key and computing various addrss forms.
|
||||
|
||||
Tests were verfified against [EthereumJS](https:/\/github.com/ethereumjs) and custom
|
||||
scripts created to directly interact with Geth and cpp implementations.
|
||||
|
||||
//See: ``accounts.json.gz``//
|
||||
|
||||
_table: Properties
|
||||
|
||||
| **Property** | **Meaning** |
|
||||
| name | The testcase name |
|
||||
| privateKey | The private key |
|
||||
| address | The address (lowercase) |
|
||||
| checksumAddress | The address with checksum-adjusted case |
|
||||
| icapAddress | The ICAP address |
|
||||
|
||||
_code: Example @lang<script>
|
||||
{
|
||||
"name": "random-1023",
|
||||
"address": "0x53bff74b9af2e3853f758a8d2bd61cd115d27782",
|
||||
"privateKey": "0x8ab0e165c2ea461b01cdd49aec882d179dccdbdb5c85c3f9c94c448aa65c5ace",
|
||||
"checksumAddress": "0x53bFf74b9Af2E3853f758A8D2Bd61CD115d27782",
|
||||
"icapAddress": "XE709S6NUSJR6SXQERCMYENAYYOZ2Y91M6A"
|
||||
}
|
||||
|
||||
|
||||
_heading: Contract Interface
|
||||
|
||||
Procedurally generated test cases to test ABI coding.
|
||||
|
||||
_code: Example @lang<script>
|
||||
{
|
||||
"name": "random-1999",
|
||||
"source": "contract Test {\n function test() constant returns (address, bool, bytes14[1]) {\n address a = address(0x061C7F399Ee738c97C7b7cD840892B281bf772B5);\n bool b = bool(true);\n bytes14[1] memory c;\n c[0] = bytes14(0x327621c4abe12d4f21804ed40455);\n return (a, b, c);\n }\n}\n",
|
||||
"types": "[\"address\",\"bool\",\"bytes14[1]\"]",
|
||||
"interface": "[{\"constant\":true,\"inputs\":[],\"name\":\"test\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"},{\"name\":\"\",\"type\":\"bool\"},{\"name\":\"\",\"type\":\"bytes14[1]\"}],\"type\":\"function\"}]\n",
|
||||
"bytecode": "0x6060604052610175806100126000396000f360606040526000357c010000000000000000000000000000000000000000000000000000000090048063f8a8fd6d1461003957610037565b005b610046600480505061009d565b604051808473ffffffffffffffffffffffffffffffffffffffff1681526020018315158152602001826001602002808383829060006004602084601f0104600f02600301f150905001935050505060405180910390f35b600060006020604051908101604052806001905b60008152602001906001900390816100b157905050600060006020604051908101604052806001905b60008152602001906001900390816100da5790505073061c7f399ee738c97c7b7cd840892b281bf772b59250600191506d327621c4abe12d4f21804ed404557201000000000000000000000000000000000000028160006001811015610002579090602002019071ffffffffffffffffffffffffffffffffffff191690818152602001505082828295509550955061016d565b50505090919256",
|
||||
"result": "0x000000000000000000000000061c7f399ee738c97c7b7cd840892b281bf772b50000000000000000000000000000000000000000000000000000000000000001327621c4abe12d4f21804ed40455000000000000000000000000000000000000",
|
||||
"values": "[{\"type\":\"string\",\"value\":\"0x061C7F399Ee738c97C7b7cD840892B281bf772B5\"},{\"type\":\"boolean\",\"value\":true},[{\"type\":\"buffer\",\"value\":\"0x327621c4abe12d4f21804ed40455\"}]]",
|
||||
"normalizedValues": "[{\"type\":\"string\",\"value\":\"0x061C7F399Ee738c97C7b7cD840892B281bf772B5\"},{\"type\":\"boolean\",\"value\":true},[{\"type\":\"buffer\",\"value\":\"0x327621c4abe12d4f21804ed40455\"}]]",
|
||||
"runtimeBytecode": "0x60606040526000357c010000000000000000000000000000000000000000000000000000000090048063f8a8fd6d1461003957610037565b005b610046600480505061009d565b604051808473ffffffffffffffffffffffffffffffffffffffff1681526020018315158152602001826001602002808383829060006004602084601f0104600f02600301f150905001935050505060405180910390f35b600060006020604051908101604052806001905b60008152602001906001900390816100b157905050600060006020604051908101604052806001905b60008152602001906001900390816100da5790505073061c7f399ee738c97c7b7cd840892b281bf772b59250600191506d327621c4abe12d4f21804ed404557201000000000000000000000000000000000000028160006001811015610002579090602002019071ffffffffffffffffffffffffffffffffffff191690818152602001505082828295509550955061016d565b50505090919256"
|
||||
}
|
||||
|
||||
|
||||
_heading: Contract Signatures
|
||||
|
||||
Computed ABI signatures and the selector hash.
|
||||
|
||||
_code: Example @lang<script>
|
||||
{
|
||||
"name": "random-1999",
|
||||
"sigHash": "0xf51e9244",
|
||||
"abi": "[{\"constant\":false,\"inputs\":[{\"name\":\"r0\",\"type\":\"string[2]\"},{\"name\":\"r1\",\"type\":\"uint128\"},{\"components\":[{\"name\":\"a\",\"type\":\"bytes\"},{\"name\":\"b\",\"type\":\"bytes\"},{\"name\":\"c\",\"type\":\"bytes\"}],\"name\":\"r2\",\"type\":\"tuple\"},{\"name\":\"r3\",\"type\":\"bytes\"}],\"name\":\"testSig\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"test\",\"outputs\":[{\"name\":\"r0\",\"type\":\"string[2]\"},{\"name\":\"r1\",\"type\":\"uint128\"},{\"components\":[{\"name\":\"a\",\"type\":\"bytes\"},{\"name\":\"b\",\"type\":\"bytes\"},{\"name\":\"c\",\"type\":\"bytes\"}],\"name\":\"r2\",\"type\":\"tuple\"},{\"name\":\"r3\",\"type\":\"bytes\"}],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"}]",
|
||||
"signature": "testSig(string[2],uint128,(bytes,bytes,bytes),bytes)"
|
||||
}
|
||||
|
||||
_heading: Hashes
|
||||
|
||||
_code: Examples @lang<script>
|
||||
{
|
||||
"data": "0x3718a88ceb214c1480c32a9d",
|
||||
"keccak256": "0x82d7d2dc3d384ddb289f41917b8280675bb1283f4fe2b601ac7c8f0a2c2824fa",
|
||||
"sha512": "0xe93462bb1de62ba3e6a980c3cb0b61728d3f771cea9680b0fa947b6f8fb2198a2690a3a837495c753b57f936401258dfe333a819e85f958b7d786fb9ab2b066c",
|
||||
"sha256": "0xe761d897e667aa72141dd729264c393c4ddda5c62312bbd21b0f4d954eba1a8d"
|
||||
}
|
||||
|
||||
|
||||
_heading: Hierarchal Deterministic Node (BIP-32)
|
||||
|
||||
Tests for [BIP-32](link-bip-32) HD Wallets.
|
||||
|
||||
_code: Example @lang<script>
|
||||
{
|
||||
"name": "trezor-23",
|
||||
"entropy": "0xf585c11aec520db57dd353c69554b21a89b20fb0650966fa0a9d6f74fd989d8f",
|
||||
"mnemonic": "void come effort suffer camp survey warrior heavy shoot primary clutch crush open amazing screen patrol group space point ten exist slush involve unfold",
|
||||
"locale": "en",
|
||||
"password": "TREZOR",
|
||||
"hdnodes": [
|
||||
{
|
||||
"path": "m",
|
||||
"address": "0xfd8eb95169ce57eab52fb69bc6922e9b6454d9aa",
|
||||
"privateKey": "0x679bf92c04cf16307053cbed33784f3c4266b362bf5f3d7ee13bed6f2719743c"
|
||||
},
|
||||
{
|
||||
"address": "0xada964e9f10c4fc9787f9e17f00c63fe188722b0",
|
||||
"privateKey": "0xdcbcb48a2b11eef0aab93a8f88d83f60a3aaabb34f9ffdbe939b8f059b30f2b7",
|
||||
"path": "m/8'/8'/2/3/4"
|
||||
},
|
||||
{
|
||||
"privateKey": "0x10fd3776145dbeccb3d6925e4fdc0d58b452fce40cb8760b12f8b4223fafdfa6",
|
||||
"address": "0xf3f6b1ef343d5f5f231a2287e801a46add43eb06",
|
||||
"path": "m/1'/3'"
|
||||
},
|
||||
{
|
||||
"address": "0xb7b0fdb6e0f79f0529e95400903321e8a601b411",
|
||||
"privateKey": "0x093a8ff506c95a2b79d397aed59703f6212ff3084731c2f03089b069ae76e69d",
|
||||
"path": "m/8'/4'/7'"
|
||||
},
|
||||
{
|
||||
"path": "m/7'/5'/11",
|
||||
"privateKey": "0x6bd79da4dfa7dd0abf566a011bdb7cba0d28bba9ca249ba25880d5dabf861b42",
|
||||
"address": "0x1b3ad5fa50ae32875748107f4b2160829cc10536"
|
||||
},
|
||||
{
|
||||
"path": "m/9'/6'/2'/7'/3'",
|
||||
"address": "0x42eb4bed59f3291d02387cf0fb23098c55d82611",
|
||||
"privateKey": "0xfc173acba7bc8bb2c434965d9e99f5a221f81add421bae96a891d08d60be11dd"
|
||||
}
|
||||
],
|
||||
"seed": "0x01f5bced59dec48e362f2c45b5de68b9fd6c92c6634f44d6d40aab69056506f0e35524a518034ddc1192e1dacd32c1ed3eaa3c3b131c88ed8e7e54c49a5d0998"
|
||||
}
|
||||
|
||||
|
||||
_heading: ENS Namehash
|
||||
|
||||
Test cases for the [ENS Namehash Algorithm](link-namehash).
|
||||
|
||||
_code: Examples
|
||||
{
|
||||
"expected": "0x33868cc5c3fd3a9cd3adbc1e868ea133d2218f60dc2660c3bc48d8b1f4961384",
|
||||
"name": "ViTalIk.WALlet.Eth",
|
||||
"test": "mixed case"
|
||||
}
|
||||
|
||||
|
||||
_heading: RLP Coder
|
||||
|
||||
_code: Examples @lang<script>
|
||||
{
|
||||
"name": "arrayWithNullString3",
|
||||
"encoded": "0xc3808080",
|
||||
"decoded": [ "0x", "0x", "0x" ]
|
||||
}
|
||||
|
||||
|
||||
_heading: Solidity Hashes
|
||||
|
||||
Tests for the non-standard packed form of the Solidity hash functions.
|
||||
|
||||
These tests were created by procedurally generating random signatures and
|
||||
values that match those signatures, constructing the equivalent Soldity,
|
||||
compiling it and deploying it to a Parity node then evaluating the response.
|
||||
|
||||
_code: Example @lang<script>
|
||||
{
|
||||
"name": "random-1999",
|
||||
"keccak256": "0x7d98f1144a0cd689f720aa2f11f0a73bd52a2da1117175bc4bacd93c130966a1",
|
||||
"ripemd160": "0x59384617f8a06efd57ab106c9e0c20c3e64137ac000000000000000000000000",
|
||||
"sha256": "0xf9aeea729ff39f8d372d8552bca81eb2a3c5d433dc8f98140040a03b7d81ac92",
|
||||
"values": [
|
||||
"0xcdffcb5242e6",
|
||||
"0xc1e101b60ebe4688",
|
||||
"0x5819f0ef5537796e43bdcd48309f717d6f7ccffa",
|
||||
"0xec3f3f9f",
|
||||
false,
|
||||
true
|
||||
],
|
||||
"types": [
|
||||
"int184",
|
||||
"int176",
|
||||
"address",
|
||||
"int64",
|
||||
"bool",
|
||||
"bool"
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
_heading: Transactions
|
||||
|
||||
Serialized signed and unsigned transactions with both EIP-155 enabled and
|
||||
disabled.
|
||||
|
||||
_code: Examples @lang<script>
|
||||
{
|
||||
"name": "random-998",
|
||||
"privateKey": "0xd16c8076a15f7fb583f05dc12686fe526bc59d298f1eb7b9a237b458133d1dec",
|
||||
"signedTransactionChainId5": "0xf8708391d450848517cfba8736fcf36da03ee4949577303fd4e0acbe72c6c116acab5bf63f0b1e9c8365fdc7827dc82ea059891894eb180cb7c6c45a52f62d2103420d3ad0bc3ba518d0a25ed910842522a0155c0ea2aee2ea82e75843aab297420bad907d46809d046b13d692928f4d78aa",
|
||||
"gasLimit": "0x36fcf36da03ee4",
|
||||
"to": "0x9577303fd4e0acbe72c6c116acab5bf63f0b1e9c",
|
||||
"data": "0x7dc8",
|
||||
"accountAddress": "0x6d4a6aff30ca5ca4b8422eea0ebcb669c7d79859",
|
||||
"unsignedTransaction": "0xed8391d450848517cfba8736fcf36da03ee4949577303fd4e0acbe72c6c116acab5bf63f0b1e9c8365fdc7827dc8",
|
||||
"nonce": "0x91d450",
|
||||
"gasPrice": "0x8517cfba",
|
||||
"signedTransaction": "0xf8708391d450848517cfba8736fcf36da03ee4949577303fd4e0acbe72c6c116acab5bf63f0b1e9c8365fdc7827dc81ba05030832331e6be48c95e1569a1ca9505c495486f72d6009b3a30fadfa05d9686a05cd3116b416d2362da1e9b0ca7fb1856c4e591cc22e63b395bd881ce2d3735e6",
|
||||
"unsignedTransactionChainId5": "0xf08391d450848517cfba8736fcf36da03ee4949577303fd4e0acbe72c6c116acab5bf63f0b1e9c8365fdc7827dc8058080",
|
||||
"value": "0x65fdc7"
|
||||
}
|
||||
|
||||
|
||||
_heading: Units
|
||||
|
||||
Unit conversion.
|
||||
|
||||
_code: Example @lang<script>
|
||||
{
|
||||
"name": "one-two-three-3",
|
||||
"gwei_format": "-1234567890123456.789012345",
|
||||
"ether_format": "-1234567.890123456789012345",
|
||||
"gwei": "-1234567890123456.789012345",
|
||||
"ether": "-1234567.890123456789012345",
|
||||
"finney": "-1234567890.123456789012345",
|
||||
"wei": "-1234567890123456789012345",
|
||||
"finney_format": "-1234567890.123456789012345"
|
||||
}
|
||||
|
||||
|
||||
_heading: Wallets
|
||||
|
||||
Tests for the JSON keystore format.
|
||||
|
||||
_code: Example @lang<script>
|
||||
{
|
||||
"mnemonic": null,
|
||||
"name": "secretstorage_password",
|
||||
"type": "secret-storage",
|
||||
"password": "foo",
|
||||
"privateKey": "0xf03e581353c794928373fb0893bc731aefc4c4e234e643f3a46998b03cd4d7c5",
|
||||
"hasAddress": true,
|
||||
"json": "{\"address\":\"88a5c2d9919e46f883eb62f7b8dd9d0cc45bc290\",\"Crypto\":{\"cipher\":\"aes-128-ctr\",\"ciphertext\":\"10adcc8bcaf49474c6710460e0dc974331f71ee4c7baa7314b4a23d25fd6c406\",\"cipherparams\":{\"iv\":\"1dcdf13e49cea706994ed38804f6d171\"},\"kdf\":\"scrypt\",\"kdfparams\":{\"dklen\":32,\"n\":262144,\"p\":1,\"r\":8,\"salt\":\"bbfa53547e3e3bfcc9786a2cbef8504a5031d82734ecef02153e29daeed658fd\"},\"mac\":\"1cf53b5ae8d75f8c037b453e7c3c61b010225d916768a6b145adf5cf9cb3a703\"},\"id\":\"fb1280c0-d646-4e40-9550-7026b1be504a\",\"version\":3}\n",
|
||||
"address": "0x88a5c2d9919e46f883eb62f7b8dd9d0cc45bc290"
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ contract.value()
|
||||
<div class="nav previous"><a href="/v5/api/contract/contract/"><span class="arrow">←</span>Contract</a></div>
|
||||
<div class="nav next"><a href="/v5/api/contract/example/">Example: ERC-20 Contract<span class="arrow">→</span></a></div>
|
||||
</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 3, 2020, 1:44am.</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 5, 2020, 12:0am.</div>
|
||||
</div>
|
||||
<script src="/v5/static/script.js" type="text/javascript"></script>
|
||||
</body>
|
||||
|
||||
@@ -109,7 +109,7 @@
|
||||
<div class="nav previous"><a href="/v5/api/contract/"><span class="arrow">←</span>Contract Interaction</a></div>
|
||||
<div class="nav next"><a href="/v5/api/contract/contract-factory/">ContractFactory<span class="arrow">→</span></a></div>
|
||||
</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 3, 2020, 1:44am.</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 5, 2020, 12:0am.</div>
|
||||
</div>
|
||||
<script src="/v5/static/script.js" type="text/javascript"></script>
|
||||
</body>
|
||||
|
||||
@@ -127,7 +127,7 @@
|
||||
<div class="nav previous"><a href="/v5/api/contract/contract-factory/"><span class="arrow">←</span>ContractFactory</a></div>
|
||||
<div class="nav next"><a href="/v5/api/signer/">Signers<span class="arrow">→</span></a></div>
|
||||
</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 3, 2020, 1:44am.</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 5, 2020, 12:0am.</div>
|
||||
</div>
|
||||
<script src="/v5/static/script.js" type="text/javascript"></script>
|
||||
</body>
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<div class="nav previous"><a href="/v5/api/"><span class="arrow">←</span>Application Programming Interface</a></div>
|
||||
<div class="nav next"><a href="/v5/api/contract/contract/">Contract<span class="arrow">→</span></a></div>
|
||||
</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 3, 2020, 1:44am.</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 5, 2020, 12:0am.</div>
|
||||
</div>
|
||||
<script src="/v5/static/script.js" type="text/javascript"></script>
|
||||
</body>
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
<div class="nav previous"><a href="/v5/api/other/hardware/"><span class="arrow">←</span>Hardware Wallets</a></div>
|
||||
<div class="nav next"><a href="/v5/cli/">Command Line Interfaces<span class="arrow">→</span></a></div>
|
||||
</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 3, 2020, 1:44am.</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 5, 2020, 12:0am.</div>
|
||||
</div>
|
||||
<script src="/v5/static/script.js" type="text/javascript"></script>
|
||||
</body>
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
<div class="nav previous"><a href="/v5/concepts/security/"><span class="arrow">←</span>Security</a></div>
|
||||
<div class="nav next"><a href="/v5/api/contract/">Contract Interaction<span class="arrow">→</span></a></div>
|
||||
</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 3, 2020, 1:44am.</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 5, 2020, 12:0am.</div>
|
||||
</div>
|
||||
<script src="/v5/static/script.js" type="text/javascript"></script>
|
||||
</body>
|
||||
|
||||
@@ -69,7 +69,7 @@
|
||||
<div class="nav previous"><a href="/v5/api/other/assembly/dialect/"><span class="arrow">←</span>Ethers ASM Dialect</a></div>
|
||||
<div class="nav next"><a href="/v5/api/other/assembly/ast/">Abstract Syntax Tree<span class="arrow">→</span></a></div>
|
||||
</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 3, 2020, 1:44am.</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 5, 2020, 12:0am.</div>
|
||||
</div>
|
||||
<script src="/v5/static/script.js" type="text/javascript"></script>
|
||||
</body>
|
||||
|
||||
@@ -87,7 +87,7 @@
|
||||
<div class="nav previous"><a href="/v5/api/other/assembly/api/"><span class="arrow">←</span>Utilities</a></div>
|
||||
<div class="nav next"><a href="/v5/api/other/hardware/">Hardware Wallets<span class="arrow">→</span></a></div>
|
||||
</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 3, 2020, 1:44am.</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 5, 2020, 12:0am.</div>
|
||||
</div>
|
||||
<script src="/v5/static/script.js" type="text/javascript"></script>
|
||||
</body>
|
||||
|
||||
@@ -77,7 +77,7 @@
|
||||
<div class="nav previous"><a href="/v5/api/other/assembly/"><span class="arrow">←</span>Assembly</a></div>
|
||||
<div class="nav next"><a href="/v5/api/other/assembly/api/">Utilities<span class="arrow">→</span></a></div>
|
||||
</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 3, 2020, 1:44am.</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 5, 2020, 12:0am.</div>
|
||||
</div>
|
||||
<script src="/v5/static/script.js" type="text/javascript"></script>
|
||||
</body>
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
<div class="nav previous"><a href="/v5/api/other/"><span class="arrow">←</span>Other Libraries</a></div>
|
||||
<div class="nav next"><a href="/v5/api/other/assembly/dialect/">Ethers ASM Dialect<span class="arrow">→</span></a></div>
|
||||
</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 3, 2020, 1:44am.</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 5, 2020, 12:0am.</div>
|
||||
</div>
|
||||
<script src="/v5/static/script.js" type="text/javascript"></script>
|
||||
</body>
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
<div class="nav previous"><a href="/v5/api/other/assembly/ast/"><span class="arrow">←</span>Abstract Syntax Tree</a></div>
|
||||
<div class="nav next"><a href="/v5/api/experimental/">Experimental<span class="arrow">→</span></a></div>
|
||||
</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 3, 2020, 1:44am.</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 5, 2020, 12:0am.</div>
|
||||
</div>
|
||||
<script src="/v5/static/script.js" type="text/javascript"></script>
|
||||
</body>
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
<div class="nav previous"><a href="/v5/api/utils/wordlists/"><span class="arrow">←</span>Wordlists</a></div>
|
||||
<div class="nav next"><a href="/v5/api/other/assembly/">Assembly<span class="arrow">→</span></a></div>
|
||||
</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 3, 2020, 1:44am.</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 5, 2020, 12:0am.</div>
|
||||
</div>
|
||||
<script src="/v5/static/script.js" type="text/javascript"></script>
|
||||
</body>
|
||||
|
||||
@@ -128,7 +128,7 @@ provider = new AlchemyProvider("homestead", apiKey);
|
||||
<div class="nav previous"><a href="/v5/api/providers/jsonrpc-provider/"><span class="arrow">←</span>JsonRpcProvider</a></div>
|
||||
<div class="nav next"><a href="/v5/api/providers/other/">Other Providers<span class="arrow">→</span></a></div>
|
||||
</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 3, 2020, 1:44am.</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 5, 2020, 12:0am.</div>
|
||||
</div>
|
||||
<script src="/v5/static/script.js" type="text/javascript"></script>
|
||||
</body>
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
<div class="nav previous"><a href="/v5/api/signer/"><span class="arrow">←</span>Signers</a></div>
|
||||
<div class="nav next"><a href="/v5/api/providers/provider/">Provider<span class="arrow">→</span></a></div>
|
||||
</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 3, 2020, 1:44am.</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 5, 2020, 12:0am.</div>
|
||||
</div>
|
||||
<script src="/v5/static/script.js" type="text/javascript"></script>
|
||||
</body>
|
||||
|
||||
@@ -61,7 +61,7 @@
|
||||
<div class="nav previous"><a href="/v5/api/providers/provider/"><span class="arrow">←</span>Provider</a></div>
|
||||
<div class="nav next"><a href="/v5/api/providers/api-providers/">API Providers<span class="arrow">→</span></a></div>
|
||||
</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 3, 2020, 1:44am.</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 5, 2020, 12:0am.</div>
|
||||
</div>
|
||||
<script src="/v5/static/script.js" type="text/javascript"></script>
|
||||
</body>
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
|
||||
<div class="property show-anchors"><div class="signature"><span class="path">ipcProvider</span><span class="symbol">.</span><span class="method">path</span> <span class="arrow">⇒</span> <span class="returns">string</span><div class="anchors"></div></div><div class="body"><p>The path this <a href="/v5/api/providers/provider/">Provider</a> is connected to.</p>
|
||||
|
||||
</div></div><a name="UrlJsonRpcProvider"></a><a name="other-providers--UrlJsonRpcProvider"></a><h2 class="show-anchors"><div>UrlJsonRpcProvider<span class="inherits"> inherits <a href="/v5/api/providers/jsonrpc-provider/">JsonRpcProvider</a></span><div class="anchors"><a class="self" href="/v5/api/providers/other/#UrlJsonRpcProvider"></a><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/providers/src.ts/url-json-rpc-provider.ts#L35">source</a></div></div></h2><p>This class is intended to be sub-classed and not used directly. It simplifies creating a <a href="/v5/api/providers/provider/">Provider</a> where a normal <a href="/v5/api/providers/jsonrpc-provider/">JsonRpcProvider</a> would suffice, with a little extra effort needed to generate the JSON-RPC URL.</p>
|
||||
</div></div><a name="UrlJsonRpcProvider"></a><a name="other-providers--UrlJsonRpcProvider"></a><h2 class="show-anchors"><div>UrlJsonRpcProvider<span class="inherits"> inherits <a href="/v5/api/providers/jsonrpc-provider/">JsonRpcProvider</a></span><div class="anchors"><a class="self" href="/v5/api/providers/other/#UrlJsonRpcProvider"></a><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/providers/src.ts/url-json-rpc-provider.ts#L49">source</a></div></div></h2><p>This class is intended to be sub-classed and not used directly. It simplifies creating a <a href="/v5/api/providers/provider/">Provider</a> where a normal <a href="/v5/api/providers/jsonrpc-provider/">JsonRpcProvider</a> would suffice, with a little extra effort needed to generate the JSON-RPC URL.</p>
|
||||
|
||||
<div class="property show-anchors"><div class="signature"><span class="modifier">new </span><span class="path">ethers</span><span class="symbol">.</span><span class="path">providers</span><span class="symbol">.</span><span class="method">UrlJsonRpcProvider</span><span class="symbol">(</span> <span class="symbol">[</span> <span class="param">network</span> <span class="symbol">[</span> <span class="symbol">,</span> <span class="param">apiKey</span> <span class="symbol">]</span> <span class="symbol">]</span> <span class="symbol">)</span><div class="anchors"></div></div><div class="body"><p>Sub-classes do not need to override this. Instead they should override the static method <code class="inline">getUrl</code> and optionally <code class="inline">getApiKey</code>.</p>
|
||||
|
||||
@@ -101,7 +101,7 @@
|
||||
<div class="nav previous"><a href="/v5/api/providers/api-providers/"><span class="arrow">←</span>API Providers</a></div>
|
||||
<div class="nav next"><a href="/v5/api/providers/types/">Types<span class="arrow">→</span></a></div>
|
||||
</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 3, 2020, 1:44am.</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 5, 2020, 12:0am.</div>
|
||||
</div>
|
||||
<script src="/v5/static/script.js" type="text/javascript"></script>
|
||||
</body>
|
||||
|
||||
@@ -33,7 +33,7 @@ Returns the number of transactions *address* has ever **sent**, as of *blockTag*
|
||||
```javascript
|
||||
// Get the balance for an account...
|
||||
provider.getBalance("ricmoo.firefly.eth");
|
||||
// { Promise: { BigNumber: "1585454034436018765" } }
|
||||
// { Promise: { BigNumber: "1578527309436018765" } }
|
||||
|
||||
// Get the code for a contract...
|
||||
provider.getCode("registrar.firefly.eth");
|
||||
@@ -45,7 +45,7 @@ provider.getStorageAt("registrar.firefly.eth", 0)
|
||||
|
||||
// Get transaction count of an account...
|
||||
provider.getTransactionCount("ricmoo.firefly.eth");
|
||||
// { Promise: 670 }
|
||||
// { Promise: 673 }
|
||||
```
|
||||
|
||||
Blocks Methods
|
||||
@@ -96,7 +96,7 @@ provider.getBlockWithTransactions(100004)
|
||||
// blockHash: '0xf93283571ae16dcecbe1816adc126954a739350cd1523a1559eabeae155fbb63',
|
||||
// blockNumber: 100004,
|
||||
// chainId: 0,
|
||||
// confirmations: 10284646,
|
||||
// confirmations: 10297123,
|
||||
// creates: null,
|
||||
// data: '0x',
|
||||
// from: '0xcf00A85f3826941e7A25BFcF9Aac575d40410852',
|
||||
@@ -177,16 +177,16 @@ provider.getNetwork()
|
||||
|
||||
// The current block number
|
||||
provider.getBlockNumber()
|
||||
// { Promise: 10384649 }
|
||||
// { Promise: 10397126 }
|
||||
|
||||
// Get the current suggested gas price (in wei)...
|
||||
gasPrice = await provider.getGasPrice()
|
||||
// { BigNumber: "41000000000" }
|
||||
// { BigNumber: "19000001123" }
|
||||
|
||||
// ...often this gas price is easier to understand or
|
||||
// display to the user in gwei (giga-wei, or 1e9 wei)
|
||||
utils.formatUnits(gasPrice, "gwei")
|
||||
// '41.0'
|
||||
// '19.000001123'
|
||||
```
|
||||
|
||||
Transactions Methods
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
</div></div><div class="code-title"><div>Account Examples</div></div><div class="code"><span class="comment">// Get the balance for an account...
|
||||
</span>provider.getBalance("ricmoo.firefly.eth");
|
||||
<span class="result ok">// { Promise: { BigNumber: "1585454034436018765" } }
|
||||
<span class="result ok">// { Promise: { BigNumber: "1578527309436018765" } }
|
||||
</span>
|
||||
<span class="comment">// Get the code for a contract...
|
||||
</span>provider.getCode("registrar.firefly.eth");
|
||||
@@ -41,7 +41,7 @@
|
||||
</span>
|
||||
<span class="comment">// Get transaction count of an account...
|
||||
</span>provider.getTransactionCount("ricmoo.firefly.eth");
|
||||
<span class="result ok">// { Promise: 670 }
|
||||
<span class="result ok">// { Promise: 673 }
|
||||
</span></div><a name="Provider--block-methods"></a><a name="Provider--Provider--block-methods"></a><h2 class="show-anchors"><div>Blocks Methods<div class="anchors"><a class="self" href="/v5/api/providers/provider/#Provider--block-methods"></a></div></div></h2>
|
||||
<a name="Provider-getBlock"></a><div class="property show-anchors"><div class="signature"><span class="path">provider</span><span class="symbol">.</span><span class="method">getBlock</span><span class="symbol">(</span> <span class="param">block</span> <span class="symbol">)</span> <span class="arrow">⇒</span> <span class="returns">Promise< <a href="/v5/api/providers/types/#providers-Block">Block</a> ></span><div class="anchors"><a class="self" href="/v5/api/providers/provider/#Provider-getBlock"></a><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/providers/src.ts/base-provider.ts#L936">source</a></div></div><div class="body"><p>Get the <i>block</i> from the network, where the <code class="inline">result.transactions</code> is a list of transaction hashes.</p>
|
||||
|
||||
@@ -81,7 +81,7 @@ provider.getBlockWithTransactions(100004)
|
||||
</span><span class="result ok">// blockHash: '0xf93283571ae16dcecbe1816adc126954a739350cd1523a1559eabeae155fbb63',
|
||||
</span><span class="result ok">// blockNumber: 100004,
|
||||
</span><span class="result ok">// chainId: 0,
|
||||
</span><span class="result ok">// confirmations: 10284646,
|
||||
</span><span class="result ok">// confirmations: 10297123,
|
||||
</span><span class="result ok">// creates: null,
|
||||
</span><span class="result ok">// data: '0x',
|
||||
</span><span class="result ok">// from: '0xcf00A85f3826941e7A25BFcF9Aac575d40410852',
|
||||
@@ -139,16 +139,16 @@ provider.getBlockWithTransactions(100004)
|
||||
</span>
|
||||
<span class="comment">// The current block number
|
||||
</span>provider.getBlockNumber()
|
||||
<span class="result ok">// { Promise: 10384649 }
|
||||
<span class="result ok">// { Promise: 10397126 }
|
||||
</span>
|
||||
<span class="comment">// Get the current suggested gas price (in wei)...
|
||||
</span>gasPrice = await provider.getGasPrice()
|
||||
<span class="result ok">// { BigNumber: "41000000000" }
|
||||
<span class="result ok">// { BigNumber: "19000001123" }
|
||||
</span>
|
||||
<span class="comment">// ...often this gas price is easier to understand or
|
||||
</span><span class="comment">// display to the user in gwei (giga-wei, or 1e9 wei)
|
||||
</span>utils.formatUnits(gasPrice, "gwei")
|
||||
<span class="result ok">// '41.0'
|
||||
<span class="result ok">// '19.000001123'
|
||||
</span></div><a name="Provider--transaction-methods"></a><a name="Provider--Provider--transaction-methods"></a><h2 class="show-anchors"><div>Transactions Methods<div class="anchors"><a class="self" href="/v5/api/providers/provider/#Provider--transaction-methods"></a></div></div></h2>
|
||||
<a name="Provider-call"></a><div class="property show-anchors"><div class="signature"><span class="path">provider</span><span class="symbol">.</span><span class="method">call</span><span class="symbol">(</span> <span class="param">transaction</span> <span class="symbol">[</span> <span class="symbol">,</span> <span class="param">blockTag</span> = <span class="param">latest</span> <span class="symbol">]</span> <span class="symbol">)</span> <span class="arrow">⇒</span> <span class="returns">Promise< string< <a href="/v5/api/utils/bytes/#DataHexString">DataHexString</a> > ></span><div class="anchors"><a class="self" href="/v5/api/providers/provider/#Provider-call"></a><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/providers/src.ts/base-provider.ts#L836">source</a></div></div><div class="body"><p>Returns the result of executing the <i>transaction</i>, using <i>call</i>. A call does not require any ether, but cannot change any state. This is useful for calling gettings on Contracts.</p>
|
||||
|
||||
@@ -250,7 +250,7 @@ provider.on("error", (tx) => {
|
||||
<div class="nav previous"><a href="/v5/api/providers/"><span class="arrow">←</span>Providers</a></div>
|
||||
<div class="nav next"><a href="/v5/api/providers/jsonrpc-provider/">JsonRpcProvider<span class="arrow">→</span></a></div>
|
||||
</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 3, 2020, 1:44am.</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 5, 2020, 12:0am.</div>
|
||||
</div>
|
||||
<script src="/v5/static/script.js" type="text/javascript"></script>
|
||||
</body>
|
||||
|
||||
@@ -187,7 +187,7 @@
|
||||
<div class="nav previous"><a href="/v5/api/providers/other/"><span class="arrow">←</span>Other Providers</a></div>
|
||||
<div class="nav next"><a href="/v5/api/utils/">Utilities<span class="arrow">→</span></a></div>
|
||||
</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 3, 2020, 1:44am.</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 5, 2020, 12:0am.</div>
|
||||
</div>
|
||||
<script src="/v5/static/script.js" type="text/javascript"></script>
|
||||
</body>
|
||||
|
||||
@@ -285,7 +285,7 @@ contract = new ethers.Contract("dai.tokens.ethers.eth", abi, signer)
|
||||
|
||||
// Get the number of tokens for this account
|
||||
tokens = await contract.balanceOf(signer.getAddress())
|
||||
// { BigNumber: "8814410125722568213383" }
|
||||
// { BigNumber: "9709905125722568213383" }
|
||||
|
||||
//
|
||||
// Pre-flight (check for revert) on DAI from the signer
|
||||
|
||||
@@ -215,7 +215,7 @@ contract = new ethers.Contract("dai.tokens.ethers.eth", abi, signer)
|
||||
|
||||
<span class="comment">// Get the number of tokens for this account
|
||||
</span>tokens = await contract.balanceOf(signer.getAddress())
|
||||
<span class="result ok">// { BigNumber: "8814410125722568213383" }
|
||||
<span class="result ok">// { BigNumber: "9709905125722568213383" }
|
||||
</span>
|
||||
//
|
||||
<span class="comment">// Pre-flight (check for revert) on DAI from the signer
|
||||
@@ -247,7 +247,7 @@ contract = new ethers.Contract("dai.tokens.ethers.eth", abi, signer)
|
||||
<div class="nav previous"><a href="/v5/api/contract/example/"><span class="arrow">←</span>Example: ERC-20 Contract</a></div>
|
||||
<div class="nav next"><a href="/v5/api/providers/">Providers<span class="arrow">→</span></a></div>
|
||||
</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 3, 2020, 1:44am.</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 5, 2020, 12:0am.</div>
|
||||
</div>
|
||||
<script src="/v5/static/script.js" type="text/javascript"></script>
|
||||
</body>
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
<div class="nav previous"><a href="/v5/api/utils/abi/"><span class="arrow">←</span>Application Binary Interface</a></div>
|
||||
<div class="nav next"><a href="/v5/api/utils/abi/formats/">ABI Formats<span class="arrow">→</span></a></div>
|
||||
</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 3, 2020, 1:44am.</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 5, 2020, 12:0am.</div>
|
||||
</div>
|
||||
<script src="/v5/static/script.js" type="text/javascript"></script>
|
||||
</body>
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
<div class="nav previous"><a href="/v5/api/utils/abi/coder/"><span class="arrow">←</span>AbiCoder</a></div>
|
||||
<div class="nav next"><a href="/v5/api/utils/abi/fragments/">Fragments<span class="arrow">→</span></a></div>
|
||||
</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 3, 2020, 1:44am.</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 5, 2020, 12:0am.</div>
|
||||
</div>
|
||||
<script src="/v5/static/script.js" type="text/javascript"></script>
|
||||
</body>
|
||||
|
||||
@@ -131,7 +131,7 @@
|
||||
<div class="nav previous"><a href="/v5/api/utils/abi/formats/"><span class="arrow">←</span>ABI Formats</a></div>
|
||||
<div class="nav next"><a href="/v5/api/utils/abi/interface/">Interface<span class="arrow">→</span></a></div>
|
||||
</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 3, 2020, 1:44am.</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 5, 2020, 12:0am.</div>
|
||||
</div>
|
||||
<script src="/v5/static/script.js" type="text/javascript"></script>
|
||||
</body>
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
<div class="nav previous"><a href="/v5/api/utils/"><span class="arrow">←</span>Utilities</a></div>
|
||||
<div class="nav next"><a href="/v5/api/utils/abi/coder/">AbiCoder<span class="arrow">→</span></a></div>
|
||||
</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 3, 2020, 1:44am.</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 5, 2020, 12:0am.</div>
|
||||
</div>
|
||||
<script src="/v5/static/script.js" type="text/javascript"></script>
|
||||
</body>
|
||||
|
||||
@@ -122,7 +122,7 @@
|
||||
<div class="nav previous"><a href="/v5/api/utils/abi/fragments/"><span class="arrow">←</span>Fragments</a></div>
|
||||
<div class="nav next"><a href="/v5/api/utils/address/">Addresses<span class="arrow">→</span></a></div>
|
||||
</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 3, 2020, 1:44am.</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 5, 2020, 12:0am.</div>
|
||||
</div>
|
||||
<script src="/v5/static/script.js" type="text/javascript"></script>
|
||||
</body>
|
||||
|
||||
@@ -62,7 +62,7 @@
|
||||
<div class="nav previous"><a href="/v5/api/utils/abi/interface/"><span class="arrow">←</span>Interface</a></div>
|
||||
<div class="nav next"><a href="/v5/api/utils/bignumber/">BigNumber<span class="arrow">→</span></a></div>
|
||||
</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 3, 2020, 1:44am.</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 5, 2020, 12:0am.</div>
|
||||
</div>
|
||||
<script src="/v5/static/script.js" type="text/javascript"></script>
|
||||
</body>
|
||||
|
||||
@@ -85,7 +85,7 @@ BigNumber.from(42n)
|
||||
|
||||
// Numbers outside the safe range fail:
|
||||
BigNumber.from(Number.MAX_SAFE_INTEGER);
|
||||
// Error: overflow (fault="overflow", operation="BigNumber.from", value=9007199254740991, code=NUMERIC_FAULT, version=bignumber/5.0.2)
|
||||
// Error: overflow (fault="overflow", operation="BigNumber.from", value=9007199254740991, code=NUMERIC_FAULT, version=bignumber/5.0.3)
|
||||
```
|
||||
|
||||
Methods
|
||||
|
||||
@@ -77,7 +77,7 @@ one2
|
||||
</span>
|
||||
<span class="comment">// Numbers outside the safe range fail:
|
||||
</span>BigNumber.from(Number.MAX_SAFE_INTEGER);
|
||||
<span class="result error">// Error: overflow (fault="overflow", operation="BigNumber.from", value=9007199254740991, code=NUMERIC_FAULT, version=bignumber/5.0.2)
|
||||
<span class="result error">// Error: overflow (fault="overflow", operation="BigNumber.from", value=9007199254740991, code=NUMERIC_FAULT, version=bignumber/5.0.3)
|
||||
</span></div><a name="BigNumber--methods"></a><a name="BigNumber--BigNumber--methods"></a><h2 class="show-anchors"><div>Methods<div class="anchors"><a class="self" href="/v5/api/utils/bignumber/#BigNumber--methods"></a></div></div></h2><p>The BigNumber class is immutable, so no operations can change the value it represents.</p>
|
||||
|
||||
<a name="BigNumber--BigNumber--methods--math-operations"></a><h3 class="show-anchors"><div>Math Operations<div class="anchors"><a class="self" href="/v5/api/utils/bignumber/#BigNumber--BigNumber--methods--math-operations"></a></div></div></h3>
|
||||
@@ -95,7 +95,7 @@ one2
|
||||
|
||||
</div></div><div class="property show-anchors"><div class="signature"><span class="path">BigNumber</span><span class="symbol">.</span><span class="method">abs</span><span class="symbol">(</span> <span class="symbol">)</span> <span class="arrow">⇒</span> <span class="returns"><a href="/v5/api/utils/bignumber/">BigNumber</a></span><div class="anchors"><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/bignumber/src.ts/bignumber.ts#L64">source</a></div></div><div class="body"><p>Returns a BigNumber with the absolute value of <i>BigNumber</i>.</p>
|
||||
|
||||
</div></div><div class="property show-anchors"><div class="signature"><span class="path">BigNumber</span><span class="symbol">.</span><span class="method">mask</span><span class="symbol">(</span> <span class="param">bitcount</span> <span class="symbol">)</span> <span class="arrow">⇒</span> <span class="returns"><a href="/v5/api/utils/bignumber/">BigNumber</a></span><div class="anchors"><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/bignumber/src.ts/bignumber.ts#L127">source</a></div></div><div class="body"><p>Returns a BigNumber with the value of <i>BigNumber</i> with bits beyond the <i>bitcount</i> least significant bits set to zero.</p>
|
||||
</div></div><div class="property show-anchors"><div class="signature"><span class="path">BigNumber</span><span class="symbol">.</span><span class="method">mask</span><span class="symbol">(</span> <span class="param">bitcount</span> <span class="symbol">)</span> <span class="arrow">⇒</span> <span class="returns"><a href="/v5/api/utils/bignumber/">BigNumber</a></span><div class="anchors"><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/bignumber/src.ts/bignumber.ts#L131">source</a></div></div><div class="body"><p>Returns a BigNumber with the value of <i>BigNumber</i> with bits beyond the <i>bitcount</i> least significant bits set to zero.</p>
|
||||
|
||||
</div></div><a name="BigNumber--BigNumber--methods--two-s-compliment"></a><h3 class="show-anchors"><div>Two's Compliment<div class="anchors"><a class="self" href="/v5/api/utils/bignumber/#BigNumber--BigNumber--methods--two-s-compliment"></a></div></div></h3><p><a href="https://en.wikipedia.org/wiki/Two%27s_complement">Two's Complicment</a> is an elegant method used to encode and decode fixed-width signed values while efficiently preserving mathematic operations. Most users will not need to interact with these.</p>
|
||||
|
||||
@@ -104,29 +104,29 @@ one2
|
||||
</div></div><div class="property show-anchors"><div class="signature"><span class="path">BigNumber</span><span class="symbol">.</span><span class="method">toTwos</span><span class="symbol">(</span> <span class="param">bitwidth</span> <span class="symbol">)</span> <span class="arrow">⇒</span> <span class="returns"><a href="/v5/api/utils/bignumber/">BigNumber</a></span><div class="anchors"><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/bignumber/src.ts/bignumber.ts#L60">source</a></div></div><div class="body"><p>Returns a BigNumber with the value of <i>BigNumber</i> converted to twos-compliment with <i>bitwidth</i>.</p>
|
||||
|
||||
</div></div><a name="BigNumber--BigNumber--methods--comparison-and-equivalence"></a><h3 class="show-anchors"><div>Comparison and Equivalence<div class="anchors"><a class="self" href="/v5/api/utils/bignumber/#BigNumber--BigNumber--methods--comparison-and-equivalence"></a></div></div></h3>
|
||||
<div class="property show-anchors"><div class="signature"><span class="path">BigNumber</span><span class="symbol">.</span><span class="method">eq</span><span class="symbol">(</span> <span class="param">otherValue</span> <span class="symbol">)</span> <span class="arrow">⇒</span> <span class="returns">boolean</span><div class="anchors"><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/bignumber/src.ts/bignumber.ts#L148">source</a></div></div><div class="body"><p>Returns true if and only if the value of <i>BigNumber</i> is equal to <i>otherValue</i>.</p>
|
||||
<div class="property show-anchors"><div class="signature"><span class="path">BigNumber</span><span class="symbol">.</span><span class="method">eq</span><span class="symbol">(</span> <span class="param">otherValue</span> <span class="symbol">)</span> <span class="arrow">⇒</span> <span class="returns">boolean</span><div class="anchors"><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/bignumber/src.ts/bignumber.ts#L152">source</a></div></div><div class="body"><p>Returns true if and only if the value of <i>BigNumber</i> is equal to <i>otherValue</i>.</p>
|
||||
|
||||
</div></div><div class="property show-anchors"><div class="signature"><span class="path">BigNumber</span><span class="symbol">.</span><span class="method">lt</span><span class="symbol">(</span> <span class="param">otherValue</span> <span class="symbol">)</span> <span class="arrow">⇒</span> <span class="returns">boolean</span><div class="anchors"><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/bignumber/src.ts/bignumber.ts#L152">source</a></div></div><div class="body"><p>Returns true if and only if the value of <i>BigNumber</i> <b><</b> <i>otherValue</i>.</p>
|
||||
</div></div><div class="property show-anchors"><div class="signature"><span class="path">BigNumber</span><span class="symbol">.</span><span class="method">lt</span><span class="symbol">(</span> <span class="param">otherValue</span> <span class="symbol">)</span> <span class="arrow">⇒</span> <span class="returns">boolean</span><div class="anchors"><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/bignumber/src.ts/bignumber.ts#L156">source</a></div></div><div class="body"><p>Returns true if and only if the value of <i>BigNumber</i> <b><</b> <i>otherValue</i>.</p>
|
||||
|
||||
</div></div><div class="property show-anchors"><div class="signature"><span class="path">BigNumber</span><span class="symbol">.</span><span class="method">lte</span><span class="symbol">(</span> <span class="param">otherValue</span> <span class="symbol">)</span> <span class="arrow">⇒</span> <span class="returns">boolean</span><div class="anchors"><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/bignumber/src.ts/bignumber.ts#L156">source</a></div></div><div class="body"><p>Returns true if and only if the value of <i>BigNumber</i> <b>≤</b> <i>otherValue</i>.</p>
|
||||
</div></div><div class="property show-anchors"><div class="signature"><span class="path">BigNumber</span><span class="symbol">.</span><span class="method">lte</span><span class="symbol">(</span> <span class="param">otherValue</span> <span class="symbol">)</span> <span class="arrow">⇒</span> <span class="returns">boolean</span><div class="anchors"><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/bignumber/src.ts/bignumber.ts#L160">source</a></div></div><div class="body"><p>Returns true if and only if the value of <i>BigNumber</i> <b>≤</b> <i>otherValue</i>.</p>
|
||||
|
||||
</div></div><div class="property show-anchors"><div class="signature"><span class="path">BigNumber</span><span class="symbol">.</span><span class="method">gt</span><span class="symbol">(</span> <span class="param">otherValue</span> <span class="symbol">)</span> <span class="arrow">⇒</span> <span class="returns">boolean</span><div class="anchors"><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/bignumber/src.ts/bignumber.ts#L160">source</a></div></div><div class="body"><p>Returns true if and only if the value of <i>BigNumber</i> <b>></b> <i>otherValue</i>.</p>
|
||||
</div></div><div class="property show-anchors"><div class="signature"><span class="path">BigNumber</span><span class="symbol">.</span><span class="method">gt</span><span class="symbol">(</span> <span class="param">otherValue</span> <span class="symbol">)</span> <span class="arrow">⇒</span> <span class="returns">boolean</span><div class="anchors"><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/bignumber/src.ts/bignumber.ts#L164">source</a></div></div><div class="body"><p>Returns true if and only if the value of <i>BigNumber</i> <b>></b> <i>otherValue</i>.</p>
|
||||
|
||||
</div></div><div class="property show-anchors"><div class="signature"><span class="path">BigNumber</span><span class="symbol">.</span><span class="method">gte</span><span class="symbol">(</span> <span class="param">otherValue</span> <span class="symbol">)</span> <span class="arrow">⇒</span> <span class="returns">boolean</span><div class="anchors"><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/bignumber/src.ts/bignumber.ts#L164">source</a></div></div><div class="body"><p>Returns true if and only if the value of <i>BigNumber</i> <b>≥</b> <i>otherValue</i>.</p>
|
||||
</div></div><div class="property show-anchors"><div class="signature"><span class="path">BigNumber</span><span class="symbol">.</span><span class="method">gte</span><span class="symbol">(</span> <span class="param">otherValue</span> <span class="symbol">)</span> <span class="arrow">⇒</span> <span class="returns">boolean</span><div class="anchors"><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/bignumber/src.ts/bignumber.ts#L168">source</a></div></div><div class="body"><p>Returns true if and only if the value of <i>BigNumber</i> <b>≥</b> <i>otherValue</i>.</p>
|
||||
|
||||
</div></div><div class="property show-anchors"><div class="signature"><span class="path">BigNumber</span><span class="symbol">.</span><span class="method">isZero</span><span class="symbol">(</span> <span class="symbol">)</span> <span class="arrow">⇒</span> <span class="returns">boolean</span><div class="anchors"><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/bignumber/src.ts/bignumber.ts#L172">source</a></div></div><div class="body"><p>Returns true if and only if the value of <i>BigNumber</i> is zero.</p>
|
||||
</div></div><div class="property show-anchors"><div class="signature"><span class="path">BigNumber</span><span class="symbol">.</span><span class="method">isZero</span><span class="symbol">(</span> <span class="symbol">)</span> <span class="arrow">⇒</span> <span class="returns">boolean</span><div class="anchors"><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/bignumber/src.ts/bignumber.ts#L176">source</a></div></div><div class="body"><p>Returns true if and only if the value of <i>BigNumber</i> is zero.</p>
|
||||
|
||||
</div></div><a name="BigNumber--BigNumber--methods--conversion"></a><h3 class="show-anchors"><div>Conversion<div class="anchors"><a class="self" href="/v5/api/utils/bignumber/#BigNumber--BigNumber--methods--conversion"></a></div></div></h3>
|
||||
<div class="property show-anchors"><div class="signature"><span class="path">BigNumber</span><span class="symbol">.</span><span class="method">toNumber</span><span class="symbol">(</span> <span class="symbol">)</span> <span class="arrow">⇒</span> <span class="returns">number</span><div class="anchors"><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/bignumber/src.ts/bignumber.ts#L176">source</a></div></div><div class="body"><p>Returns the value of <i>BigNumber</i> as a JavaScript value.</p>
|
||||
<div class="property show-anchors"><div class="signature"><span class="path">BigNumber</span><span class="symbol">.</span><span class="method">toNumber</span><span class="symbol">(</span> <span class="symbol">)</span> <span class="arrow">⇒</span> <span class="returns">number</span><div class="anchors"><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/bignumber/src.ts/bignumber.ts#L180">source</a></div></div><div class="body"><p>Returns the value of <i>BigNumber</i> as a JavaScript value.</p>
|
||||
|
||||
<p>This will <b>throw an error</b> if the value is greater than or equal to <i>Number.MAX_SAFE_INTEGER</i> or less than or equal to <i>Number.MIN_SAFE_INTEGER</i>.</p>
|
||||
|
||||
</div></div><div class="property show-anchors"><div class="signature"><span class="path">BigNumber</span><span class="symbol">.</span><span class="method">toString</span><span class="symbol">(</span> <span class="symbol">)</span> <span class="arrow">⇒</span> <span class="returns">string</span><div class="anchors"><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/bignumber/src.ts/bignumber.ts#L185">source</a></div></div><div class="body"><p>Returns the value of <i>BigNumber</i> as a base-10 string.</p>
|
||||
</div></div><div class="property show-anchors"><div class="signature"><span class="path">BigNumber</span><span class="symbol">.</span><span class="method">toString</span><span class="symbol">(</span> <span class="symbol">)</span> <span class="arrow">⇒</span> <span class="returns">string</span><div class="anchors"><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/bignumber/src.ts/bignumber.ts#L189">source</a></div></div><div class="body"><p>Returns the value of <i>BigNumber</i> as a base-10 string.</p>
|
||||
|
||||
</div></div><div class="property show-anchors"><div class="signature"><span class="path">BigNumber</span><span class="symbol">.</span><span class="method">toHexString</span><span class="symbol">(</span> <span class="symbol">)</span> <span class="arrow">⇒</span> <span class="returns">string< <a href="/v5/api/utils/bytes/#DataHexString">DataHexString</a> ></span><div class="anchors"><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/bignumber/src.ts/bignumber.ts#L193">source</a></div></div><div class="body"><p>Returns the value of <i>BigNumber</i> as a base-16, <code class="inline">0x</code>-prefixed <a href="/v5/api/utils/bytes/#DataHexString">DataHexString</a>.</p>
|
||||
</div></div><div class="property show-anchors"><div class="signature"><span class="path">BigNumber</span><span class="symbol">.</span><span class="method">toHexString</span><span class="symbol">(</span> <span class="symbol">)</span> <span class="arrow">⇒</span> <span class="returns">string< <a href="/v5/api/utils/bytes/#DataHexString">DataHexString</a> ></span><div class="anchors"><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/bignumber/src.ts/bignumber.ts#L197">source</a></div></div><div class="body"><p>Returns the value of <i>BigNumber</i> as a base-16, <code class="inline">0x</code>-prefixed <a href="/v5/api/utils/bytes/#DataHexString">DataHexString</a>.</p>
|
||||
|
||||
</div></div><a name="BigNumber--BigNumber--methods--inspection"></a><h3 class="show-anchors"><div>Inspection<div class="anchors"><a class="self" href="/v5/api/utils/bignumber/#BigNumber--BigNumber--methods--inspection"></a></div></div></h3>
|
||||
<div class="property show-anchors"><div class="signature"><span class="path">ethers</span><span class="symbol">.</span><span class="path">BigNumnber</span><span class="symbol">.</span><span class="method">isBigNumber</span><span class="symbol">(</span> <span class="param">object</span> <span class="symbol">)</span> <span class="arrow">⇒</span> <span class="returns">boolean</span><div class="anchors"><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/bignumber/src.ts/bignumber.ts#L246">source</a></div></div><div class="body"><p>Returns true if and only if the <i>object</i> is a BigNumber object.</p>
|
||||
<div class="property show-anchors"><div class="signature"><span class="path">ethers</span><span class="symbol">.</span><span class="path">BigNumnber</span><span class="symbol">.</span><span class="method">isBigNumber</span><span class="symbol">(</span> <span class="param">object</span> <span class="symbol">)</span> <span class="arrow">⇒</span> <span class="returns">boolean</span><div class="anchors"><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/bignumber/src.ts/bignumber.ts#L250">source</a></div></div><div class="body"><p>Returns true if and only if the <i>object</i> is a BigNumber object.</p>
|
||||
|
||||
</div></div><a name="BigNumber--BigNumber--methods--examples"></a><h3 class="show-anchors"><div>Examples<div class="anchors"><a class="self" href="/v5/api/utils/bignumber/#BigNumber--BigNumber--methods--examples"></a></div></div></h3>
|
||||
<div class="code">let a = BigNumber.from(42);
|
||||
@@ -178,7 +178,7 @@ a.mul(b);
|
||||
<div class="nav previous"><a href="/v5/api/utils/address/"><span class="arrow">←</span>Addresses</a></div>
|
||||
<div class="nav next"><a href="/v5/api/utils/bytes/">Byte Manipulation<span class="arrow">→</span></a></div>
|
||||
</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 3, 2020, 1:44am.</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 5, 2020, 12:0am.</div>
|
||||
</div>
|
||||
<script src="/v5/static/script.js" type="text/javascript"></script>
|
||||
</body>
|
||||
|
||||
@@ -164,20 +164,20 @@ Return a copy of *array* shuffled using [Fisher-Yates Shuffle](https://en.wikipe
|
||||
|
||||
```javascript
|
||||
utils.randomBytes(8)
|
||||
// Uint8Array [ 95, 9, 0, 81, 176, 49, 211, 225 ]
|
||||
// Uint8Array [ 158, 14, 185, 6, 8, 37, 214, 172 ]
|
||||
|
||||
const data = [ 1, 2, 3, 4, 5, 6, 7 ];
|
||||
|
||||
// Returns a new Array
|
||||
utils.shuffled(data);
|
||||
// [
|
||||
// 6,
|
||||
// 7,
|
||||
// 4,
|
||||
// 3,
|
||||
// 5,
|
||||
// 1,
|
||||
// 2
|
||||
// 3,
|
||||
// 4,
|
||||
// 7,
|
||||
// 2,
|
||||
// 5,
|
||||
// 6
|
||||
// ]
|
||||
|
||||
// The Original is unscathed...
|
||||
|
||||
@@ -105,20 +105,20 @@
|
||||
</div></div><a name="utils-shuffled"></a><div class="property show-anchors"><div class="signature"><span class="path">ethers</span><span class="symbol">.</span><span class="path">utils</span><span class="symbol">.</span><span class="method">shuffled</span><span class="symbol">(</span> <span class="param">array</span> <span class="symbol">)</span> <span class="arrow">⇒</span> <span class="returns">Array< any ></span><div class="anchors"><a class="self" href="/v5/api/utils/bytes/#utils-shuffled"></a><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/random/src.ts/shuffle.ts#L3">source</a></div></div><div class="body"><p>Return a copy of <i>array</i> shuffled using <a href="https://en.wikipedia.org/wiki/Fisher-Yates_shuffle">Fisher-Yates Shuffle</a>.</p>
|
||||
|
||||
</div></div><div class="code-title"><div>Examples</div></div><div class="code">utils.randomBytes(8)
|
||||
<span class="result ok">// Uint8Array [ 95, 9, 0, 81, 176, 49, 211, 225 ]
|
||||
<span class="result ok">// Uint8Array [ 158, 14, 185, 6, 8, 37, 214, 172 ]
|
||||
</span>
|
||||
const data = [ 1, 2, 3, 4, 5, 6, 7 ];
|
||||
|
||||
<span class="comment">// Returns a new Array
|
||||
</span>utils.shuffled(data);
|
||||
<span class="result ok">// [
|
||||
</span><span class="result ok">// 6,
|
||||
</span><span class="result ok">// 7,
|
||||
</span><span class="result ok">// 4,
|
||||
</span><span class="result ok">// 3,
|
||||
</span><span class="result ok">// 5,
|
||||
</span><span class="result ok">// 1,
|
||||
</span><span class="result ok">// 2
|
||||
</span><span class="result ok">// 3,
|
||||
</span><span class="result ok">// 4,
|
||||
</span><span class="result ok">// 7,
|
||||
</span><span class="result ok">// 2,
|
||||
</span><span class="result ok">// 5,
|
||||
</span><span class="result ok">// 6
|
||||
</span><span class="result ok">// ]
|
||||
</span>
|
||||
<span class="comment">// The Original is unscathed...
|
||||
@@ -138,7 +138,7 @@ const data = [ 1, 2, 3, 4, 5, 6, 7 ];
|
||||
<div class="nav previous"><a href="/v5/api/utils/bignumber/"><span class="arrow">←</span>BigNumber</a></div>
|
||||
<div class="nav next"><a href="/v5/api/utils/constants/">Constants<span class="arrow">→</span></a></div>
|
||||
</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 3, 2020, 1:44am.</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 5, 2020, 12:0am.</div>
|
||||
</div>
|
||||
<script src="/v5/static/script.js" type="text/javascript"></script>
|
||||
</body>
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
<div class="nav previous"><a href="/v5/api/utils/bytes/"><span class="arrow">←</span>Byte Manipulation</a></div>
|
||||
<div class="nav next"><a href="/v5/api/utils/display-logic/">Display Logic and Input<span class="arrow">→</span></a></div>
|
||||
</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 3, 2020, 1:44am.</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 5, 2020, 12:0am.</div>
|
||||
</div>
|
||||
<script src="/v5/static/script.js" type="text/javascript"></script>
|
||||
</body>
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
<div class="nav previous"><a href="/v5/api/utils/constants/"><span class="arrow">←</span>Constants</a></div>
|
||||
<div class="nav next"><a href="/v5/api/utils/encoding/">Encoding Utilities<span class="arrow">→</span></a></div>
|
||||
</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 3, 2020, 1:44am.</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 5, 2020, 12:0am.</div>
|
||||
</div>
|
||||
<script src="/v5/static/script.js" type="text/javascript"></script>
|
||||
</body>
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
<div class="nav previous"><a href="/v5/api/utils/display-logic/"><span class="arrow">←</span>Display Logic and Input</a></div>
|
||||
<div class="nav next"><a href="/v5/api/utils/fixednumber/">FixedNumber<span class="arrow">→</span></a></div>
|
||||
</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 3, 2020, 1:44am.</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 5, 2020, 12:0am.</div>
|
||||
</div>
|
||||
<script src="/v5/static/script.js" type="text/javascript"></script>
|
||||
</body>
|
||||
|
||||
@@ -90,7 +90,7 @@
|
||||
<div class="nav previous"><a href="/v5/api/utils/encoding/"><span class="arrow">←</span>Encoding Utilities</a></div>
|
||||
<div class="nav next"><a href="/v5/api/utils/hashing/">Hashing Algorithms<span class="arrow">→</span></a></div>
|
||||
</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 3, 2020, 1:44am.</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 5, 2020, 12:0am.</div>
|
||||
</div>
|
||||
<script src="/v5/static/script.js" type="text/javascript"></script>
|
||||
</body>
|
||||
|
||||
@@ -151,7 +151,7 @@ utils.soliditySha256([ "int16", "uint48" ], [ -1, 12 ])
|
||||
<div class="nav previous"><a href="/v5/api/utils/fixednumber/"><span class="arrow">←</span>FixedNumber</a></div>
|
||||
<div class="nav next"><a href="/v5/api/utils/hdnode/">HD Wallet<span class="arrow">→</span></a></div>
|
||||
</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 3, 2020, 1:44am.</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 5, 2020, 12:0am.</div>
|
||||
</div>
|
||||
<script src="/v5/static/script.js" type="text/javascript"></script>
|
||||
</body>
|
||||
|
||||
@@ -88,7 +88,7 @@
|
||||
<div class="nav previous"><a href="/v5/api/utils/hashing/"><span class="arrow">←</span>Hashing Algorithms</a></div>
|
||||
<div class="nav next"><a href="/v5/api/utils/logger/">Logging<span class="arrow">→</span></a></div>
|
||||
</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 3, 2020, 1:44am.</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 5, 2020, 12:0am.</div>
|
||||
</div>
|
||||
<script src="/v5/static/script.js" type="text/javascript"></script>
|
||||
</body>
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
<div class="nav previous"><a href="/v5/api/providers/types/"><span class="arrow">←</span>Types</a></div>
|
||||
<div class="nav next"><a href="/v5/api/utils/abi/">Application Binary Interface<span class="arrow">→</span></a></div>
|
||||
</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 3, 2020, 1:44am.</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 5, 2020, 12:0am.</div>
|
||||
</div>
|
||||
<script src="/v5/static/script.js" type="text/javascript"></script>
|
||||
</body>
|
||||
|
||||
@@ -132,7 +132,7 @@
|
||||
<div class="nav previous"><a href="/v5/api/utils/hdnode/"><span class="arrow">←</span>HD Wallet</a></div>
|
||||
<div class="nav next"><a href="/v5/api/utils/properties/">Property Utilities<span class="arrow">→</span></a></div>
|
||||
</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 3, 2020, 1:44am.</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 5, 2020, 12:0am.</div>
|
||||
</div>
|
||||
<script src="/v5/static/script.js" type="text/javascript"></script>
|
||||
</body>
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
<div class="nav previous"><a href="/v5/api/utils/logger/"><span class="arrow">←</span>Logging</a></div>
|
||||
<div class="nav next"><a href="/v5/api/utils/signing-key/">Signing Key<span class="arrow">→</span></a></div>
|
||||
</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 3, 2020, 1:44am.</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 5, 2020, 12:0am.</div>
|
||||
</div>
|
||||
<script src="/v5/static/script.js" type="text/javascript"></script>
|
||||
</body>
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
<div class="nav previous"><a href="/v5/api/utils/properties/"><span class="arrow">←</span>Property Utilities</a></div>
|
||||
<div class="nav next"><a href="/v5/api/utils/strings/">Strings<span class="arrow">→</span></a></div>
|
||||
</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 3, 2020, 1:44am.</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 5, 2020, 12:0am.</div>
|
||||
</div>
|
||||
<script src="/v5/static/script.js" type="text/javascript"></script>
|
||||
</body>
|
||||
|
||||
@@ -98,7 +98,7 @@
|
||||
<div class="nav previous"><a href="/v5/api/utils/signing-key/"><span class="arrow">←</span>Signing Key</a></div>
|
||||
<div class="nav next"><a href="/v5/api/utils/transactions/">Transactions<span class="arrow">→</span></a></div>
|
||||
</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 3, 2020, 1:44am.</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 5, 2020, 12:0am.</div>
|
||||
</div>
|
||||
<script src="/v5/static/script.js" type="text/javascript"></script>
|
||||
</body>
|
||||
|
||||
@@ -81,7 +81,7 @@
|
||||
<div class="nav previous"><a href="/v5/api/utils/strings/"><span class="arrow">←</span>Strings</a></div>
|
||||
<div class="nav next"><a href="/v5/api/utils/web/">Web Utilities<span class="arrow">→</span></a></div>
|
||||
</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 3, 2020, 1:44am.</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 5, 2020, 12:0am.</div>
|
||||
</div>
|
||||
<script src="/v5/static/script.js" type="text/javascript"></script>
|
||||
</body>
|
||||
|
||||
@@ -61,7 +61,7 @@
|
||||
<div class="nav previous"><a href="/v5/api/utils/transactions/"><span class="arrow">←</span>Transactions</a></div>
|
||||
<div class="nav next"><a href="/v5/api/utils/wordlists/">Wordlists<span class="arrow">→</span></a></div>
|
||||
</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 3, 2020, 1:44am.</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 5, 2020, 12:0am.</div>
|
||||
</div>
|
||||
<script src="/v5/static/script.js" type="text/javascript"></script>
|
||||
</body>
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
<div class="nav previous"><a href="/v5/api/utils/web/"><span class="arrow">←</span>Web Utilities</a></div>
|
||||
<div class="nav next"><a href="/v5/api/other/">Other Libraries<span class="arrow">→</span></a></div>
|
||||
</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 3, 2020, 1:44am.</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 5, 2020, 12:0am.</div>
|
||||
</div>
|
||||
<script src="/v5/static/script.js" type="text/javascript"></script>
|
||||
</body>
|
||||
|
||||
@@ -180,7 +180,7 @@ return(0, #myContract)
|
||||
<div class="nav previous"><a href="/v5/cli/ethers/"><span class="arrow">←</span>Sandbox Utility</a></div>
|
||||
<div class="nav next"><a href="/v5/cli/ens/">Ethereum Naming Service<span class="arrow">→</span></a></div>
|
||||
</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 3, 2020, 1:44am.</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 5, 2020, 12:0am.</div>
|
||||
</div>
|
||||
<script src="/v5/static/script.js" type="text/javascript"></script>
|
||||
</body>
|
||||
|
||||
@@ -94,7 +94,7 @@ OTHER OPTIONS
|
||||
<div class="nav previous"><a href="/v5/cli/asm/"><span class="arrow">←</span>Assembler</a></div>
|
||||
<div class="nav next"><a href="/v5/cli/typescript/">TypeScript<span class="arrow">→</span></a></div>
|
||||
</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 3, 2020, 1:44am.</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 5, 2020, 12:0am.</div>
|
||||
</div>
|
||||
<script src="/v5/static/script.js" type="text/javascript"></script>
|
||||
</body>
|
||||
|
||||
@@ -209,7 +209,7 @@ homestead></div><div class="definition container-box warning"><div class="ter
|
||||
<div class="nav previous"><a href="/v5/cli/"><span class="arrow">←</span>Command Line Interfaces</a></div>
|
||||
<div class="nav next"><a href="/v5/cli/asm/">Assembler<span class="arrow">→</span></a></div>
|
||||
</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 3, 2020, 1:44am.</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 5, 2020, 12:0am.</div>
|
||||
</div>
|
||||
<script src="/v5/static/script.js" type="text/javascript"></script>
|
||||
</body>
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
<div class="nav previous"><a href="/v5/api/experimental/"><span class="arrow">←</span>Experimental</a></div>
|
||||
<div class="nav next"><a href="/v5/cli/ethers/">Sandbox Utility<span class="arrow">→</span></a></div>
|
||||
</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 3, 2020, 1:44am.</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 5, 2020, 12:0am.</div>
|
||||
</div>
|
||||
<script src="/v5/static/script.js" type="text/javascript"></script>
|
||||
</body>
|
||||
|
||||
@@ -102,7 +102,7 @@
|
||||
<div class="nav previous"><a href="/v5/cli/typescript/"><span class="arrow">←</span>TypeScript</a></div>
|
||||
<div class="nav next"><a href="/v5/cookbook/">Cookbook<span class="arrow">→</span></a></div>
|
||||
</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 3, 2020, 1:44am.</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 5, 2020, 12:0am.</div>
|
||||
</div>
|
||||
<script src="/v5/static/script.js" type="text/javascript"></script>
|
||||
</body>
|
||||
|
||||
@@ -42,7 +42,7 @@ OTHER OPTIONS
|
||||
<div class="nav previous"><a href="/v5/cli/ens/"><span class="arrow">←</span>Ethereum Naming Service</a></div>
|
||||
<div class="nav next"><a href="/v5/cli/plugin/">Making Your Own<span class="arrow">→</span></a></div>
|
||||
</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 3, 2020, 1:44am.</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 5, 2020, 12:0am.</div>
|
||||
</div>
|
||||
<script src="/v5/static/script.js" type="text/javascript"></script>
|
||||
</body>
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
<div class="nav previous"><!--PREV_LINK--></div>
|
||||
<div class="nav next"><!--NEXT_LINK--></div>
|
||||
</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 3, 2020, 1:44am.</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 5, 2020, 12:0am.</div>
|
||||
</div>
|
||||
<script src="/v5/static/script.js" type="text/javascript"></script>
|
||||
</body>
|
||||
|
||||
@@ -150,7 +150,7 @@ const contract = new Contract(tokenAddress, abi, provider);
|
||||
<div class="nav previous"><a href="/v5/concepts/"><span class="arrow">←</span>Ethereum Basics</a></div>
|
||||
<div class="nav next"><a href="/v5/concepts/gas/">Gas<span class="arrow">→</span></a></div>
|
||||
</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 3, 2020, 1:44am.</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 5, 2020, 12:0am.</div>
|
||||
</div>
|
||||
<script src="/v5/static/script.js" type="text/javascript"></script>
|
||||
</body>
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
<div class="nav previous"><a href="/v5/concepts/events/"><span class="arrow">←</span>Events</a></div>
|
||||
<div class="nav next"><a href="/v5/concepts/security/">Security<span class="arrow">→</span></a></div>
|
||||
</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 3, 2020, 1:44am.</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 5, 2020, 12:0am.</div>
|
||||
</div>
|
||||
<script src="/v5/static/script.js" type="text/javascript"></script>
|
||||
</body>
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<div class="nav previous"><a href="/v5/getting-started/"><span class="arrow">←</span>Getting Started</a></div>
|
||||
<div class="nav next"><a href="/v5/concepts/events/">Events<span class="arrow">→</span></a></div>
|
||||
</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 3, 2020, 1:44am.</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 5, 2020, 12:0am.</div>
|
||||
</div>
|
||||
<script src="/v5/static/script.js" type="text/javascript"></script>
|
||||
</body>
|
||||
|
||||
@@ -62,7 +62,7 @@
|
||||
<div class="nav previous"><a href="/v5/concepts/gas/"><span class="arrow">←</span>Gas</a></div>
|
||||
<div class="nav next"><a href="/v5/api/">Application Programming Interface<span class="arrow">→</span></a></div>
|
||||
</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 3, 2020, 1:44am.</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 5, 2020, 12:0am.</div>
|
||||
</div>
|
||||
<script src="/v5/static/script.js" type="text/javascript"></script>
|
||||
</body>
|
||||
|
||||
@@ -81,7 +81,7 @@
|
||||
<div class="nav previous"><a href="/v5/testing/"><span class="arrow">←</span>Testing</a></div>
|
||||
<div class="nav next"><a href="/v5/documentation/">Flatworm Docs<span class="arrow">→</span></a></div>
|
||||
</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 3, 2020, 1:44am.</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 5, 2020, 12:0am.</div>
|
||||
</div>
|
||||
<script src="/v5/static/script.js" type="text/javascript"></script>
|
||||
</body>
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
<div class="nav previous"><a href="/v5/cli/plugin/"><span class="arrow">←</span>Making Your Own</a></div>
|
||||
<div class="nav next"><a href="/v5/migration/">Migration Guide<span class="arrow">→</span></a></div>
|
||||
</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 3, 2020, 1:44am.</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 5, 2020, 12:0am.</div>
|
||||
</div>
|
||||
<script src="/v5/static/script.js" type="text/javascript"></script>
|
||||
</body>
|
||||
|
||||
@@ -282,7 +282,7 @@ $bottom: This just represents an example of
|
||||
<div class="nav previous"><a href="/v5/contributing/"><span class="arrow">←</span>Contributing and Hacking</a></div>
|
||||
<div class="nav next"><a href="/v5/license/">License and Copyright<span class="arrow">→</span></a></div>
|
||||
</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 3, 2020, 1:44am.</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 5, 2020, 12:0am.</div>
|
||||
</div>
|
||||
<script src="/v5/static/script.js" type="text/javascript"></script>
|
||||
</body>
|
||||
|
||||
@@ -30,8 +30,10 @@ import { ethers } from "ethers";
|
||||
### Web Browser
|
||||
|
||||
```
|
||||
<script src="https://cdn.ethers.io/lib/ethers-5.0.esm.min.js"
|
||||
type="application/javascipt"></script>
|
||||
<script type="module">
|
||||
import { ethers } from "https://cdn.ethers.io/lib/ethers-5.0.esm.min.js";
|
||||
// Your code here...
|
||||
</script>
|
||||
```
|
||||
|
||||
```
|
||||
@@ -65,7 +67,7 @@ const signer = provider.getSigner()
|
||||
```javascript
|
||||
// Look up the current block number
|
||||
provider.getBlockNumber()
|
||||
// { Promise: 10384649 }
|
||||
// { Promise: 10397126 }
|
||||
|
||||
// Get the balance of an account (by address or ENS name)
|
||||
balance = await provider.getBalance("ethers.eth")
|
||||
@@ -133,11 +135,11 @@ daiContract.symbol()
|
||||
|
||||
// Get the balance of an address
|
||||
balance = await daiContract.balanceOf("ricmoo.firefly.eth")
|
||||
// { BigNumber: "8814410125722568213383" }
|
||||
// { BigNumber: "9709905125722568213383" }
|
||||
|
||||
// Format the DAI for displaying to the user
|
||||
ethers.utils.formatUnits(balance, 18)
|
||||
// '8814.410125722568213383'
|
||||
// '9709.905125722568213383'
|
||||
```
|
||||
|
||||
### State Changing Methods
|
||||
@@ -292,7 +294,7 @@ Signing Messages
|
||||
// logging into a service, such as CryptoKitties simply
|
||||
// pass the string in.
|
||||
signature = await signer.signMessage("Hello World");
|
||||
// '0x9671c8b89473038593fddda5875debcb517dbfe79bd25119f6b0878bcd6c5e9d497e5d7f08cb7314da5d2a04b49bee0918d0b9e11744ee5a738b94e38986575f1c'
|
||||
// '0x7b8d663c680b165bb7b0601a65d730f532fa6427b2e30f1d91ff1d929712b3a50b427a672b90c1dc48a4e5fbde292fbded51f670ab57d15d5794b6ff015649611c'
|
||||
|
||||
//
|
||||
// A common case is also signing a hash, which is 32
|
||||
@@ -309,6 +311,6 @@ messageBytes = ethers.utils.arrayify(message);
|
||||
|
||||
// To sign a hash, you most often want to sign the bytes
|
||||
signature = await signer.signMessage(messageBytes)
|
||||
// '0xfff17b9972cf8466bcde13dfc52afe6cbe39b86b1c9028d0fe4de6ab565ce01a48b7eba3663a24588e87798d924e8178f3c7c84d9363f57a9bee519f7cac50b31b'
|
||||
// '0xc791b3d29aa1754f9e392784273f076ef39ca5d81f2729c92af61f89db724a604074acbd725d9d95e1d3c9630211c8eee8e34f6d948d537dd82c11be4bcf676e1c'
|
||||
```
|
||||
|
||||
|
||||
@@ -27,8 +27,10 @@
|
||||
|
||||
<p>For quick demos or prototyping though, it can be loaded in your Web Applications from our CDN.</p>
|
||||
|
||||
<div class="code-title"><div>ES6 in the Browser</div></div><div class="code"><script src="https://cdn.ethers.io/lib/ethers-5.0.esm.min.js"
|
||||
type="application/javascipt"></script></div><div class="code-title"><div>ES3 (UMD) in the Browser</div></div><div class="code"><script src="https://cdn.ethers.io/lib/ethers-5.0.umd.min.js"
|
||||
<div class="code-title"><div>ES6 in the Browser</div></div><div class="code"><script type="module">
|
||||
import { ethers } from "https://cdn.ethers.io/lib/ethers-5.0.esm.min.js";
|
||||
// Your code here...
|
||||
</script></div><div class="code-title"><div>ES3 (UMD) in the Browser</div></div><div class="code"><script src="https://cdn.ethers.io/lib/ethers-5.0.umd.min.js"
|
||||
type="application/javascipt"></script></div><a name="getting-started--glossary"></a><a name="getting-started--getting-started--glossary"></a><h2 class="show-anchors"><div>Common Terminology<div class="anchors"><a class="self" href="/v5/getting-started/#getting-started--glossary"></a></div></div></h2><p>This section needs work...</p>
|
||||
|
||||
<table class="table minimal"><tr><td align="left"><b>Provider</b></td><td align="left">A Provider (in ethers) is a class which provides an abstraction for a connection to the Ethereum Network. It provides read-only access to the Blockchain and its status.</td><td class="fix"> </td></tr><tr><td align="left"><b>Signer</b></td><td align="left">A Signer is a class which (usually) in some way directly or indirectly has access to a private key, which can sign messages and transactions to authorize the network to charge your account ether to perform operations.</td><td class="fix"> </td></tr><tr><td align="left"><b>Contract</b></td><td align="left">A Contract is an abstraction which represents a connection to a specific contract on the Ethereum Network, so that it can be used like a normal JavaScipt object.</td><td class="fix"> </td></tr><tr><td class="table-title" colspan="2">Common Terms</td><td class="fix"> </td></tr></table><a name="getting-started--connecting"></a><a name="getting-started--getting-started--connecting"></a><h2 class="show-anchors"><div>Connecting to Ethereum: Metamask<div class="anchors"><a class="self" href="/v5/getting-started/#getting-started--connecting"></a></div></div></h2><p>The quickest and easiest way to experiment and begin developing on Ethereum is to use <a href="https://metamask.io/">Metamask</a>, which is a browser extension that provides:</p>
|
||||
@@ -47,7 +49,7 @@
|
||||
|
||||
<div class="code-title"><div>Basic Queries</div></div><div class="code"><span class="comment">// Look up the current block number
|
||||
</span>provider.getBlockNumber()
|
||||
<span class="result ok">// { Promise: 10384649 }
|
||||
<span class="result ok">// { Promise: 10397126 }
|
||||
</span>
|
||||
<span class="comment">// Get the balance of an account (by address or ENS name)
|
||||
</span>balance = await provider.getBalance("ethers.eth")
|
||||
@@ -115,11 +117,11 @@
|
||||
</span>
|
||||
<span class="comment">// Get the balance of an address
|
||||
</span>balance = await daiContract.balanceOf("ricmoo.firefly.eth")
|
||||
<span class="result ok">// { BigNumber: "8814410125722568213383" }
|
||||
<span class="result ok">// { BigNumber: "9709905125722568213383" }
|
||||
</span>
|
||||
<span class="comment">// Format the DAI for displaying to the user
|
||||
</span>ethers.utils.formatUnits(balance, 18)
|
||||
<span class="result ok">// '8814.410125722568213383'
|
||||
<span class="result ok">// '9709.905125722568213383'
|
||||
</span></div><a name="getting-started--writing"></a><a name="getting-started--getting-started--contracts--getting-started--writing"></a><h3 class="show-anchors"><div>State Changing Methods<div class="anchors"><a class="self" href="/v5/getting-started/#getting-started--writing"></a></div></div></h3>
|
||||
<div class="code-title"><div>Sending DAI</div></div><div class="code"><span class="comment">// The DAI Contract is currently connected to the Provider,
|
||||
</span><span class="comment">// which is read-only. We need to connect to a Signer, so
|
||||
@@ -257,7 +259,7 @@ filter = daiContract.filters.Transfer(null, myAddress)
|
||||
</span><span class="comment">// logging into a service, such as CryptoKitties simply
|
||||
</span><span class="comment">// pass the string in.
|
||||
</span>signature = await signer.signMessage("Hello World");
|
||||
<span class="result ok">// '0x9671c8b89473038593fddda5875debcb517dbfe79bd25119f6b0878bcd6c5e9d497e5d7f08cb7314da5d2a04b49bee0918d0b9e11744ee5a738b94e38986575f1c'
|
||||
<span class="result ok">// '0x7b8d663c680b165bb7b0601a65d730f532fa6427b2e30f1d91ff1d929712b3a50b427a672b90c1dc48a4e5fbde292fbded51f670ab57d15d5794b6ff015649611c'
|
||||
</span>
|
||||
//
|
||||
<span class="comment">// A common case is also signing a hash, which is 32
|
||||
@@ -274,14 +276,14 @@ filter = daiContract.filters.Transfer(null, myAddress)
|
||||
</span>
|
||||
<span class="comment">// To sign a hash, you most often want to sign the bytes
|
||||
</span>signature = await signer.signMessage(messageBytes)
|
||||
<span class="result ok">// '0xfff17b9972cf8466bcde13dfc52afe6cbe39b86b1c9028d0fe4de6ab565ce01a48b7eba3663a24588e87798d924e8178f3c7c84d9363f57a9bee519f7cac50b31b'
|
||||
<span class="result ok">// '0xc791b3d29aa1754f9e392784273f076ef39ca5d81f2729c92af61f89db724a604074acbd725d9d95e1d3c9630211c8eee8e34f6d948d537dd82c11be4bcf676e1c'
|
||||
</span></div>
|
||||
|
||||
<div class="footer">
|
||||
<div class="nav previous"><a href="/v5/"><span class="arrow">←</span>Documentation</a></div>
|
||||
<div class="nav next"><a href="/v5/concepts/">Ethereum Basics<span class="arrow">→</span></a></div>
|
||||
</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 3, 2020, 1:44am.</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 5, 2020, 12:0am.</div>
|
||||
</div>
|
||||
<script src="/v5/static/script.js" type="text/javascript"></script>
|
||||
</body>
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
<div class="nav previous"><!--PREV_LINK--></div>
|
||||
<div class="nav next"><!--NEXT_LINK--></div>
|
||||
</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 3, 2020, 1:44am.</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 5, 2020, 12:0am.</div>
|
||||
</div>
|
||||
<script src="/v5/static/script.js" type="text/javascript"></script>
|
||||
</body>
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
<div class="nav previous"><!--PREV_LINK--></div>
|
||||
<div class="nav next"><a href="/v5/getting-started/">Getting Started<span class="arrow">→</span></a></div>
|
||||
</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 3, 2020, 1:44am.</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 5, 2020, 12:0am.</div>
|
||||
</div>
|
||||
<script src="/v5/static/script.js" type="text/javascript"></script>
|
||||
</body>
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
<div class="nav previous"><a href="/v5/documentation/"><span class="arrow">←</span>Flatworm Docs</a></div>
|
||||
<div class="nav next"><!--NEXT_LINK--></div>
|
||||
</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 3, 2020, 1:44am.</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 5, 2020, 12:0am.</div>
|
||||
</div>
|
||||
<script src="/v5/static/script.js" type="text/javascript"></script>
|
||||
</body>
|
||||
|
||||
@@ -108,7 +108,7 @@ interface.events.Transfer.decode(data, topics)
|
||||
|
||||
// v5
|
||||
interface.encodeFilterTopics("Transfer", values)
|
||||
interface.encodeEventLog("Transfer", data, topics)
|
||||
interface.decodeEventLog("Transfer", data, topics)
|
||||
```
|
||||
|
||||
### Inspection
|
||||
|
||||
@@ -97,7 +97,7 @@ interface.events.Transfer.decode(data, topics)
|
||||
|
||||
<span class="comment">// v5
|
||||
</span>interface.encodeFilterTopics("Transfer", values)
|
||||
interface.encodeEventLog("Transfer", data, topics)
|
||||
interface.decodeEventLog("Transfer", data, topics)
|
||||
</div><a name="migration-v4--interface--inspection"></a><h3 class="show-anchors"><div>Inspection<div class="anchors"><a class="self" href="/v5/migration/ethers-v4/#migration-v4--interface--inspection"></a></div></div></h3><p>Interrogating properties about a function or event can now (mostly) be done directly on the <a href="/v5/api/utils/abi/fragments/#Fragment">Fragment</a> object.</p>
|
||||
|
||||
<div class="code">// v4
|
||||
@@ -168,7 +168,7 @@ wallet.mnemonic.path
|
||||
<div class="nav previous"><a href="/v5/migration/web3/"><span class="arrow">←</span>Migration: From Web3.js</a></div>
|
||||
<div class="nav next"><a href="/v5/testing/">Testing<span class="arrow">→</span></a></div>
|
||||
</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 3, 2020, 1:44am.</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 5, 2020, 12:0am.</div>
|
||||
</div>
|
||||
<script src="/v5/static/script.js" type="text/javascript"></script>
|
||||
</body>
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
<div class="nav previous"><a href="/v5/cookbook/"><span class="arrow">←</span>Cookbook</a></div>
|
||||
<div class="nav next"><a href="/v5/migration/web3/">Migration: From Web3.js<span class="arrow">→</span></a></div>
|
||||
</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 3, 2020, 1:44am.</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 5, 2020, 12:0am.</div>
|
||||
</div>
|
||||
<script src="/v5/static/script.js" type="text/javascript"></script>
|
||||
</body>
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
<div class="nav previous"><a href="/v5/migration/"><span class="arrow">←</span>Migration Guide</a></div>
|
||||
<div class="nav next"><a href="/v5/migration/ethers-v4/">Migration: From Ethers v4<span class="arrow">→</span></a></div>
|
||||
</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 3, 2020, 1:44am.</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 5, 2020, 12:0am.</div>
|
||||
</div>
|
||||
<script src="/v5/static/script.js" type="text/javascript"></script>
|
||||
</body>
|
||||
|
||||
@@ -36,8 +36,10 @@
|
||||
|
||||
<p>For quick demos or prototyping though, it can be loaded in your Web Applications from our CDN.</p>
|
||||
|
||||
<div class="code-title"><div>ES6 in the Browser</div></div><div class="code"><script src="https://cdn.ethers.io/lib/ethers-5.0.esm.min.js"
|
||||
type="application/javascipt"></script></div><div class="code-title"><div>ES3 (UMD) in the Browser</div></div><div class="code"><script src="https://cdn.ethers.io/lib/ethers-5.0.umd.min.js"
|
||||
<div class="code-title"><div>ES6 in the Browser</div></div><div class="code"><script type="module">
|
||||
import { ethers } from "https://cdn.ethers.io/lib/ethers-5.0.esm.min.js";
|
||||
// Your code here...
|
||||
</script></div><div class="code-title"><div>ES3 (UMD) in the Browser</div></div><div class="code"><script src="https://cdn.ethers.io/lib/ethers-5.0.umd.min.js"
|
||||
type="application/javascipt"></script></div><a name="/v5/getting-started/-%23-getting-started--glossary"></a><a name="/v5/getting-started/-%23-getting-started--getting-started--glossary"></a><a name="/v5/getting-started/"></a><h2 class="show-anchors"><div>Common Terminology<div class="anchors"><a class="self" href="#/v5/getting-started/-%23-getting-started--glossary"></a></div></div></h2><p>This section needs work...</p>
|
||||
|
||||
<table class="table minimal"><tr><td align="left"><b>Provider</b></td><td align="left">A Provider (in ethers) is a class which provides an abstraction for a connection to the Ethereum Network. It provides read-only access to the Blockchain and its status.</td><td class="fix"> </td></tr><tr><td align="left"><b>Signer</b></td><td align="left">A Signer is a class which (usually) in some way directly or indirectly has access to a private key, which can sign messages and transactions to authorize the network to charge your account ether to perform operations.</td><td class="fix"> </td></tr><tr><td align="left"><b>Contract</b></td><td align="left">A Contract is an abstraction which represents a connection to a specific contract on the Ethereum Network, so that it can be used like a normal JavaScipt object.</td><td class="fix"> </td></tr><tr><td class="table-title" colspan="2">Common Terms</td><td class="fix"> </td></tr></table><a name="/v5/getting-started/-%23-getting-started--connecting"></a><a name="/v5/getting-started/-%23-getting-started--getting-started--connecting"></a><a name="/v5/getting-started/"></a><h2 class="show-anchors"><div>Connecting to Ethereum: Metamask<div class="anchors"><a class="self" href="#/v5/getting-started/-%23-getting-started--connecting"></a></div></div></h2><p>The quickest and easiest way to experiment and begin developing on Ethereum is to use <a href="https://metamask.io/">Metamask</a>, which is a browser extension that provides:</p>
|
||||
@@ -56,7 +58,7 @@
|
||||
|
||||
<div class="code-title"><div>Basic Queries</div></div><div class="code"><span class="comment">// Look up the current block number
|
||||
</span>provider.getBlockNumber()
|
||||
<span class="result ok">// { Promise: 10384649 }
|
||||
<span class="result ok">// { Promise: 10397126 }
|
||||
</span>
|
||||
<span class="comment">// Get the balance of an account (by address or ENS name)
|
||||
</span>balance = await provider.getBalance("ethers.eth")
|
||||
@@ -124,11 +126,11 @@
|
||||
</span>
|
||||
<span class="comment">// Get the balance of an address
|
||||
</span>balance = await daiContract.balanceOf("ricmoo.firefly.eth")
|
||||
<span class="result ok">// { BigNumber: "8814410125722568213383" }
|
||||
<span class="result ok">// { BigNumber: "9709905125722568213383" }
|
||||
</span>
|
||||
<span class="comment">// Format the DAI for displaying to the user
|
||||
</span>ethers.utils.formatUnits(balance, 18)
|
||||
<span class="result ok">// '8814.410125722568213383'
|
||||
<span class="result ok">// '9709.905125722568213383'
|
||||
</span></div><a name="/v5/getting-started/-%23-getting-started--writing"></a><a name="/v5/getting-started/-%23-getting-started--getting-started--contracts--getting-started--writing"></a><a name="/v5/getting-started/"></a><h3 class="show-anchors"><div>State Changing Methods<div class="anchors"><a class="self" href="#/v5/getting-started/-%23-getting-started--writing"></a></div></div></h3>
|
||||
<div class="code-title"><div>Sending DAI</div></div><div class="code"><span class="comment">// The DAI Contract is currently connected to the Provider,
|
||||
</span><span class="comment">// which is read-only. We need to connect to a Signer, so
|
||||
@@ -266,7 +268,7 @@ filter = daiContract.filters.Transfer(null, myAddress)
|
||||
</span><span class="comment">// logging into a service, such as CryptoKitties simply
|
||||
</span><span class="comment">// pass the string in.
|
||||
</span>signature = await signer.signMessage("Hello World");
|
||||
<span class="result ok">// '0x9671c8b89473038593fddda5875debcb517dbfe79bd25119f6b0878bcd6c5e9d497e5d7f08cb7314da5d2a04b49bee0918d0b9e11744ee5a738b94e38986575f1c'
|
||||
<span class="result ok">// '0x7b8d663c680b165bb7b0601a65d730f532fa6427b2e30f1d91ff1d929712b3a50b427a672b90c1dc48a4e5fbde292fbded51f670ab57d15d5794b6ff015649611c'
|
||||
</span>
|
||||
//
|
||||
<span class="comment">// A common case is also signing a hash, which is 32
|
||||
@@ -283,7 +285,7 @@ filter = daiContract.filters.Transfer(null, myAddress)
|
||||
</span>
|
||||
<span class="comment">// To sign a hash, you most often want to sign the bytes
|
||||
</span>signature = await signer.signMessage(messageBytes)
|
||||
<span class="result ok">// '0xfff17b9972cf8466bcde13dfc52afe6cbe39b86b1c9028d0fe4de6ab565ce01a48b7eba3663a24588e87798d924e8178f3c7c84d9363f57a9bee519f7cac50b31b'
|
||||
<span class="result ok">// '0xc791b3d29aa1754f9e392784273f076ef39ca5d81f2729c92af61f89db724a604074acbd725d9d95e1d3c9630211c8eee8e34f6d948d537dd82c11be4bcf676e1c'
|
||||
</span></div><div class="page-separator"></div><a name="/v5/concepts/-%23-ethereum-basics"></a><a name="/v5/concepts/"></a><h1 class="show-anchors"><div>Ethereum Basics<div class="anchors"><a class="self" href="#/v5/concepts/-%23-ethereum-basics"></a></div></div></h1><p>This is a very breif overview of some aspects of <i>Ethereum</i> and blockchains which developers can make use of or should be aware of.</p>
|
||||
|
||||
<p>This section is fairly sparse at the moment, but will be expanded as time goes on.</p>
|
||||
@@ -907,7 +909,7 @@ contract = new ethers.Contract("dai.tokens.ethers.eth", abi, signer)
|
||||
|
||||
<span class="comment">// Get the number of tokens for this account
|
||||
</span>tokens = await contract.balanceOf(signer.getAddress())
|
||||
<span class="result ok">// { BigNumber: "8814410125722568213383" }
|
||||
<span class="result ok">// { BigNumber: "9709905125722568213383" }
|
||||
</span>
|
||||
//
|
||||
<span class="comment">// Pre-flight (check for revert) on DAI from the signer
|
||||
@@ -971,7 +973,7 @@ contract = new ethers.Contract("dai.tokens.ethers.eth", abi, signer)
|
||||
|
||||
</div></div><div class="code-title"><div>Account Examples</div></div><div class="code"><span class="comment">// Get the balance for an account...
|
||||
</span>provider.getBalance("ricmoo.firefly.eth");
|
||||
<span class="result ok">// { Promise: { BigNumber: "1585454034436018765" } }
|
||||
<span class="result ok">// { Promise: { BigNumber: "1578527309436018765" } }
|
||||
</span>
|
||||
<span class="comment">// Get the code for a contract...
|
||||
</span>provider.getCode("registrar.firefly.eth");
|
||||
@@ -983,7 +985,7 @@ contract = new ethers.Contract("dai.tokens.ethers.eth", abi, signer)
|
||||
</span>
|
||||
<span class="comment">// Get transaction count of an account...
|
||||
</span>provider.getTransactionCount("ricmoo.firefly.eth");
|
||||
<span class="result ok">// { Promise: 670 }
|
||||
<span class="result ok">// { Promise: 673 }
|
||||
</span></div><a name="/v5/api/providers/provider/-%23-Provider--block-methods"></a><a name="/v5/api/providers/provider/-%23-Provider--Provider--block-methods"></a><a name="/v5/api/providers/provider/"></a><h2 class="show-anchors"><div>Blocks Methods<div class="anchors"><a class="self" href="#/v5/api/providers/provider/-%23-Provider--block-methods"></a></div></div></h2>
|
||||
<a name="/v5/api/providers/provider/-%23-Provider-getBlock"></a><div class="property show-anchors"><div class="signature"><span class="path">provider</span><span class="symbol">.</span><span class="method">getBlock</span><span class="symbol">(</span> <span class="param">block</span> <span class="symbol">)</span> <span class="arrow">⇒</span> <span class="returns">Promise< <a href="#/v5/api/providers/types/-%23-providers-Block">Block</a> ></span><div class="anchors"><a class="self" href="#/v5/api/providers/provider/-%23-Provider-getBlock"></a><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/providers/src.ts/base-provider.ts#L936">source</a></div></div><div class="body"><p>Get the <i>block</i> from the network, where the <code class="inline">result.transactions</code> is a list of transaction hashes.</p>
|
||||
|
||||
@@ -1023,7 +1025,7 @@ provider.getBlockWithTransactions(100004)
|
||||
</span><span class="result ok">// blockHash: '0xf93283571ae16dcecbe1816adc126954a739350cd1523a1559eabeae155fbb63',
|
||||
</span><span class="result ok">// blockNumber: 100004,
|
||||
</span><span class="result ok">// chainId: 0,
|
||||
</span><span class="result ok">// confirmations: 10284646,
|
||||
</span><span class="result ok">// confirmations: 10297123,
|
||||
</span><span class="result ok">// creates: null,
|
||||
</span><span class="result ok">// data: '0x',
|
||||
</span><span class="result ok">// from: '0xcf00A85f3826941e7A25BFcF9Aac575d40410852',
|
||||
@@ -1081,16 +1083,16 @@ provider.getBlockWithTransactions(100004)
|
||||
</span>
|
||||
<span class="comment">// The current block number
|
||||
</span>provider.getBlockNumber()
|
||||
<span class="result ok">// { Promise: 10384649 }
|
||||
<span class="result ok">// { Promise: 10397126 }
|
||||
</span>
|
||||
<span class="comment">// Get the current suggested gas price (in wei)...
|
||||
</span>gasPrice = await provider.getGasPrice()
|
||||
<span class="result ok">// { BigNumber: "41000000000" }
|
||||
<span class="result ok">// { BigNumber: "19000001123" }
|
||||
</span>
|
||||
<span class="comment">// ...often this gas price is easier to understand or
|
||||
</span><span class="comment">// display to the user in gwei (giga-wei, or 1e9 wei)
|
||||
</span>utils.formatUnits(gasPrice, "gwei")
|
||||
<span class="result ok">// '41.0'
|
||||
<span class="result ok">// '19.000001123'
|
||||
</span></div><a name="/v5/api/providers/provider/-%23-Provider--transaction-methods"></a><a name="/v5/api/providers/provider/-%23-Provider--Provider--transaction-methods"></a><a name="/v5/api/providers/provider/"></a><h2 class="show-anchors"><div>Transactions Methods<div class="anchors"><a class="self" href="#/v5/api/providers/provider/-%23-Provider--transaction-methods"></a></div></div></h2>
|
||||
<a name="/v5/api/providers/provider/-%23-Provider-call"></a><div class="property show-anchors"><div class="signature"><span class="path">provider</span><span class="symbol">.</span><span class="method">call</span><span class="symbol">(</span> <span class="param">transaction</span> <span class="symbol">[</span> <span class="symbol">,</span> <span class="param">blockTag</span> = <span class="param">latest</span> <span class="symbol">]</span> <span class="symbol">)</span> <span class="arrow">⇒</span> <span class="returns">Promise< string< <a href="#/v5/api/utils/bytes/-%23-DataHexString">DataHexString</a> > ></span><div class="anchors"><a class="self" href="#/v5/api/providers/provider/-%23-Provider-call"></a><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/providers/src.ts/base-provider.ts#L836">source</a></div></div><div class="body"><p>Returns the result of executing the <i>transaction</i>, using <i>call</i>. A call does not require any ether, but cannot change any state. This is useful for calling gettings on Contracts.</p>
|
||||
|
||||
@@ -1366,7 +1368,7 @@ provider = new AlchemyProvider("homestead", apiKey);
|
||||
|
||||
<div class="property show-anchors"><div class="signature"><span class="path">ipcProvider</span><span class="symbol">.</span><span class="method">path</span> <span class="arrow">⇒</span> <span class="returns">string</span><div class="anchors"></div></div><div class="body"><p>The path this <a href="#/v5/api/providers/provider/">Provider</a> is connected to.</p>
|
||||
|
||||
</div></div><a name="/v5/api/providers/other/-%23-UrlJsonRpcProvider"></a><a name="/v5/api/providers/other/-%23-other-providers--UrlJsonRpcProvider"></a><a name="/v5/api/providers/other/"></a><h2 class="show-anchors"><div>UrlJsonRpcProvider<span class="inherits"> inherits <a href="#/v5/api/providers/jsonrpc-provider/">JsonRpcProvider</a></span><div class="anchors"><a class="self" href="#/v5/api/providers/other/-%23-UrlJsonRpcProvider"></a><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/providers/src.ts/url-json-rpc-provider.ts#L35">source</a></div></div></h2><p>This class is intended to be sub-classed and not used directly. It simplifies creating a <a href="#/v5/api/providers/provider/">Provider</a> where a normal <a href="#/v5/api/providers/jsonrpc-provider/">JsonRpcProvider</a> would suffice, with a little extra effort needed to generate the JSON-RPC URL.</p>
|
||||
</div></div><a name="/v5/api/providers/other/-%23-UrlJsonRpcProvider"></a><a name="/v5/api/providers/other/-%23-other-providers--UrlJsonRpcProvider"></a><a name="/v5/api/providers/other/"></a><h2 class="show-anchors"><div>UrlJsonRpcProvider<span class="inherits"> inherits <a href="#/v5/api/providers/jsonrpc-provider/">JsonRpcProvider</a></span><div class="anchors"><a class="self" href="#/v5/api/providers/other/-%23-UrlJsonRpcProvider"></a><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/providers/src.ts/url-json-rpc-provider.ts#L49">source</a></div></div></h2><p>This class is intended to be sub-classed and not used directly. It simplifies creating a <a href="#/v5/api/providers/provider/">Provider</a> where a normal <a href="#/v5/api/providers/jsonrpc-provider/">JsonRpcProvider</a> would suffice, with a little extra effort needed to generate the JSON-RPC URL.</p>
|
||||
|
||||
<div class="property show-anchors"><div class="signature"><span class="modifier">new </span><span class="path">ethers</span><span class="symbol">.</span><span class="path">providers</span><span class="symbol">.</span><span class="method">UrlJsonRpcProvider</span><span class="symbol">(</span> <span class="symbol">[</span> <span class="param">network</span> <span class="symbol">[</span> <span class="symbol">,</span> <span class="param">apiKey</span> <span class="symbol">]</span> <span class="symbol">]</span> <span class="symbol">)</span><div class="anchors"></div></div><div class="body"><p>Sub-classes do not need to override this. Instead they should override the static method <code class="inline">getUrl</code> and optionally <code class="inline">getApiKey</code>.</p>
|
||||
|
||||
@@ -1920,7 +1922,7 @@ one2
|
||||
</span>
|
||||
<span class="comment">// Numbers outside the safe range fail:
|
||||
</span>BigNumber.from(Number.MAX_SAFE_INTEGER);
|
||||
<span class="result error">// Error: overflow (fault="overflow", operation="BigNumber.from", value=9007199254740991, code=NUMERIC_FAULT, version=bignumber/5.0.2)
|
||||
<span class="result error">// Error: overflow (fault="overflow", operation="BigNumber.from", value=9007199254740991, code=NUMERIC_FAULT, version=bignumber/5.0.3)
|
||||
</span></div><a name="/v5/api/utils/bignumber/-%23-BigNumber--methods"></a><a name="/v5/api/utils/bignumber/-%23-BigNumber--BigNumber--methods"></a><a name="/v5/api/utils/bignumber/"></a><h2 class="show-anchors"><div>Methods<div class="anchors"><a class="self" href="#/v5/api/utils/bignumber/-%23-BigNumber--methods"></a></div></div></h2><p>The BigNumber class is immutable, so no operations can change the value it represents.</p>
|
||||
|
||||
<a name="/v5/api/utils/bignumber/-%23-BigNumber--BigNumber--methods--math-operations"></a><a name="/v5/api/utils/bignumber/"></a><h3 class="show-anchors"><div>Math Operations<div class="anchors"><a class="self" href="#/v5/api/utils/bignumber/-%23-BigNumber--BigNumber--methods--math-operations"></a></div></div></h3>
|
||||
@@ -1938,7 +1940,7 @@ one2
|
||||
|
||||
</div></div><div class="property show-anchors"><div class="signature"><span class="path">BigNumber</span><span class="symbol">.</span><span class="method">abs</span><span class="symbol">(</span> <span class="symbol">)</span> <span class="arrow">⇒</span> <span class="returns"><a href="#/v5/api/utils/bignumber/">BigNumber</a></span><div class="anchors"><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/bignumber/src.ts/bignumber.ts#L64">source</a></div></div><div class="body"><p>Returns a BigNumber with the absolute value of <i>BigNumber</i>.</p>
|
||||
|
||||
</div></div><div class="property show-anchors"><div class="signature"><span class="path">BigNumber</span><span class="symbol">.</span><span class="method">mask</span><span class="symbol">(</span> <span class="param">bitcount</span> <span class="symbol">)</span> <span class="arrow">⇒</span> <span class="returns"><a href="#/v5/api/utils/bignumber/">BigNumber</a></span><div class="anchors"><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/bignumber/src.ts/bignumber.ts#L127">source</a></div></div><div class="body"><p>Returns a BigNumber with the value of <i>BigNumber</i> with bits beyond the <i>bitcount</i> least significant bits set to zero.</p>
|
||||
</div></div><div class="property show-anchors"><div class="signature"><span class="path">BigNumber</span><span class="symbol">.</span><span class="method">mask</span><span class="symbol">(</span> <span class="param">bitcount</span> <span class="symbol">)</span> <span class="arrow">⇒</span> <span class="returns"><a href="#/v5/api/utils/bignumber/">BigNumber</a></span><div class="anchors"><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/bignumber/src.ts/bignumber.ts#L131">source</a></div></div><div class="body"><p>Returns a BigNumber with the value of <i>BigNumber</i> with bits beyond the <i>bitcount</i> least significant bits set to zero.</p>
|
||||
|
||||
</div></div><a name="/v5/api/utils/bignumber/-%23-BigNumber--BigNumber--methods--two-s-compliment"></a><a name="/v5/api/utils/bignumber/"></a><h3 class="show-anchors"><div>Two's Compliment<div class="anchors"><a class="self" href="#/v5/api/utils/bignumber/-%23-BigNumber--BigNumber--methods--two-s-compliment"></a></div></div></h3><p><a href="https://en.wikipedia.org/wiki/Two%27s_complement">Two's Complicment</a> is an elegant method used to encode and decode fixed-width signed values while efficiently preserving mathematic operations. Most users will not need to interact with these.</p>
|
||||
|
||||
@@ -1947,29 +1949,29 @@ one2
|
||||
</div></div><div class="property show-anchors"><div class="signature"><span class="path">BigNumber</span><span class="symbol">.</span><span class="method">toTwos</span><span class="symbol">(</span> <span class="param">bitwidth</span> <span class="symbol">)</span> <span class="arrow">⇒</span> <span class="returns"><a href="#/v5/api/utils/bignumber/">BigNumber</a></span><div class="anchors"><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/bignumber/src.ts/bignumber.ts#L60">source</a></div></div><div class="body"><p>Returns a BigNumber with the value of <i>BigNumber</i> converted to twos-compliment with <i>bitwidth</i>.</p>
|
||||
|
||||
</div></div><a name="/v5/api/utils/bignumber/-%23-BigNumber--BigNumber--methods--comparison-and-equivalence"></a><a name="/v5/api/utils/bignumber/"></a><h3 class="show-anchors"><div>Comparison and Equivalence<div class="anchors"><a class="self" href="#/v5/api/utils/bignumber/-%23-BigNumber--BigNumber--methods--comparison-and-equivalence"></a></div></div></h3>
|
||||
<div class="property show-anchors"><div class="signature"><span class="path">BigNumber</span><span class="symbol">.</span><span class="method">eq</span><span class="symbol">(</span> <span class="param">otherValue</span> <span class="symbol">)</span> <span class="arrow">⇒</span> <span class="returns">boolean</span><div class="anchors"><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/bignumber/src.ts/bignumber.ts#L148">source</a></div></div><div class="body"><p>Returns true if and only if the value of <i>BigNumber</i> is equal to <i>otherValue</i>.</p>
|
||||
<div class="property show-anchors"><div class="signature"><span class="path">BigNumber</span><span class="symbol">.</span><span class="method">eq</span><span class="symbol">(</span> <span class="param">otherValue</span> <span class="symbol">)</span> <span class="arrow">⇒</span> <span class="returns">boolean</span><div class="anchors"><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/bignumber/src.ts/bignumber.ts#L152">source</a></div></div><div class="body"><p>Returns true if and only if the value of <i>BigNumber</i> is equal to <i>otherValue</i>.</p>
|
||||
|
||||
</div></div><div class="property show-anchors"><div class="signature"><span class="path">BigNumber</span><span class="symbol">.</span><span class="method">lt</span><span class="symbol">(</span> <span class="param">otherValue</span> <span class="symbol">)</span> <span class="arrow">⇒</span> <span class="returns">boolean</span><div class="anchors"><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/bignumber/src.ts/bignumber.ts#L152">source</a></div></div><div class="body"><p>Returns true if and only if the value of <i>BigNumber</i> <b><</b> <i>otherValue</i>.</p>
|
||||
</div></div><div class="property show-anchors"><div class="signature"><span class="path">BigNumber</span><span class="symbol">.</span><span class="method">lt</span><span class="symbol">(</span> <span class="param">otherValue</span> <span class="symbol">)</span> <span class="arrow">⇒</span> <span class="returns">boolean</span><div class="anchors"><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/bignumber/src.ts/bignumber.ts#L156">source</a></div></div><div class="body"><p>Returns true if and only if the value of <i>BigNumber</i> <b><</b> <i>otherValue</i>.</p>
|
||||
|
||||
</div></div><div class="property show-anchors"><div class="signature"><span class="path">BigNumber</span><span class="symbol">.</span><span class="method">lte</span><span class="symbol">(</span> <span class="param">otherValue</span> <span class="symbol">)</span> <span class="arrow">⇒</span> <span class="returns">boolean</span><div class="anchors"><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/bignumber/src.ts/bignumber.ts#L156">source</a></div></div><div class="body"><p>Returns true if and only if the value of <i>BigNumber</i> <b>≤</b> <i>otherValue</i>.</p>
|
||||
</div></div><div class="property show-anchors"><div class="signature"><span class="path">BigNumber</span><span class="symbol">.</span><span class="method">lte</span><span class="symbol">(</span> <span class="param">otherValue</span> <span class="symbol">)</span> <span class="arrow">⇒</span> <span class="returns">boolean</span><div class="anchors"><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/bignumber/src.ts/bignumber.ts#L160">source</a></div></div><div class="body"><p>Returns true if and only if the value of <i>BigNumber</i> <b>≤</b> <i>otherValue</i>.</p>
|
||||
|
||||
</div></div><div class="property show-anchors"><div class="signature"><span class="path">BigNumber</span><span class="symbol">.</span><span class="method">gt</span><span class="symbol">(</span> <span class="param">otherValue</span> <span class="symbol">)</span> <span class="arrow">⇒</span> <span class="returns">boolean</span><div class="anchors"><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/bignumber/src.ts/bignumber.ts#L160">source</a></div></div><div class="body"><p>Returns true if and only if the value of <i>BigNumber</i> <b>></b> <i>otherValue</i>.</p>
|
||||
</div></div><div class="property show-anchors"><div class="signature"><span class="path">BigNumber</span><span class="symbol">.</span><span class="method">gt</span><span class="symbol">(</span> <span class="param">otherValue</span> <span class="symbol">)</span> <span class="arrow">⇒</span> <span class="returns">boolean</span><div class="anchors"><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/bignumber/src.ts/bignumber.ts#L164">source</a></div></div><div class="body"><p>Returns true if and only if the value of <i>BigNumber</i> <b>></b> <i>otherValue</i>.</p>
|
||||
|
||||
</div></div><div class="property show-anchors"><div class="signature"><span class="path">BigNumber</span><span class="symbol">.</span><span class="method">gte</span><span class="symbol">(</span> <span class="param">otherValue</span> <span class="symbol">)</span> <span class="arrow">⇒</span> <span class="returns">boolean</span><div class="anchors"><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/bignumber/src.ts/bignumber.ts#L164">source</a></div></div><div class="body"><p>Returns true if and only if the value of <i>BigNumber</i> <b>≥</b> <i>otherValue</i>.</p>
|
||||
</div></div><div class="property show-anchors"><div class="signature"><span class="path">BigNumber</span><span class="symbol">.</span><span class="method">gte</span><span class="symbol">(</span> <span class="param">otherValue</span> <span class="symbol">)</span> <span class="arrow">⇒</span> <span class="returns">boolean</span><div class="anchors"><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/bignumber/src.ts/bignumber.ts#L168">source</a></div></div><div class="body"><p>Returns true if and only if the value of <i>BigNumber</i> <b>≥</b> <i>otherValue</i>.</p>
|
||||
|
||||
</div></div><div class="property show-anchors"><div class="signature"><span class="path">BigNumber</span><span class="symbol">.</span><span class="method">isZero</span><span class="symbol">(</span> <span class="symbol">)</span> <span class="arrow">⇒</span> <span class="returns">boolean</span><div class="anchors"><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/bignumber/src.ts/bignumber.ts#L172">source</a></div></div><div class="body"><p>Returns true if and only if the value of <i>BigNumber</i> is zero.</p>
|
||||
</div></div><div class="property show-anchors"><div class="signature"><span class="path">BigNumber</span><span class="symbol">.</span><span class="method">isZero</span><span class="symbol">(</span> <span class="symbol">)</span> <span class="arrow">⇒</span> <span class="returns">boolean</span><div class="anchors"><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/bignumber/src.ts/bignumber.ts#L176">source</a></div></div><div class="body"><p>Returns true if and only if the value of <i>BigNumber</i> is zero.</p>
|
||||
|
||||
</div></div><a name="/v5/api/utils/bignumber/-%23-BigNumber--BigNumber--methods--conversion"></a><a name="/v5/api/utils/bignumber/"></a><h3 class="show-anchors"><div>Conversion<div class="anchors"><a class="self" href="#/v5/api/utils/bignumber/-%23-BigNumber--BigNumber--methods--conversion"></a></div></div></h3>
|
||||
<div class="property show-anchors"><div class="signature"><span class="path">BigNumber</span><span class="symbol">.</span><span class="method">toNumber</span><span class="symbol">(</span> <span class="symbol">)</span> <span class="arrow">⇒</span> <span class="returns">number</span><div class="anchors"><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/bignumber/src.ts/bignumber.ts#L176">source</a></div></div><div class="body"><p>Returns the value of <i>BigNumber</i> as a JavaScript value.</p>
|
||||
<div class="property show-anchors"><div class="signature"><span class="path">BigNumber</span><span class="symbol">.</span><span class="method">toNumber</span><span class="symbol">(</span> <span class="symbol">)</span> <span class="arrow">⇒</span> <span class="returns">number</span><div class="anchors"><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/bignumber/src.ts/bignumber.ts#L180">source</a></div></div><div class="body"><p>Returns the value of <i>BigNumber</i> as a JavaScript value.</p>
|
||||
|
||||
<p>This will <b>throw an error</b> if the value is greater than or equal to <i>Number.MAX_SAFE_INTEGER</i> or less than or equal to <i>Number.MIN_SAFE_INTEGER</i>.</p>
|
||||
|
||||
</div></div><div class="property show-anchors"><div class="signature"><span class="path">BigNumber</span><span class="symbol">.</span><span class="method">toString</span><span class="symbol">(</span> <span class="symbol">)</span> <span class="arrow">⇒</span> <span class="returns">string</span><div class="anchors"><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/bignumber/src.ts/bignumber.ts#L185">source</a></div></div><div class="body"><p>Returns the value of <i>BigNumber</i> as a base-10 string.</p>
|
||||
</div></div><div class="property show-anchors"><div class="signature"><span class="path">BigNumber</span><span class="symbol">.</span><span class="method">toString</span><span class="symbol">(</span> <span class="symbol">)</span> <span class="arrow">⇒</span> <span class="returns">string</span><div class="anchors"><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/bignumber/src.ts/bignumber.ts#L189">source</a></div></div><div class="body"><p>Returns the value of <i>BigNumber</i> as a base-10 string.</p>
|
||||
|
||||
</div></div><div class="property show-anchors"><div class="signature"><span class="path">BigNumber</span><span class="symbol">.</span><span class="method">toHexString</span><span class="symbol">(</span> <span class="symbol">)</span> <span class="arrow">⇒</span> <span class="returns">string< <a href="#/v5/api/utils/bytes/-%23-DataHexString">DataHexString</a> ></span><div class="anchors"><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/bignumber/src.ts/bignumber.ts#L193">source</a></div></div><div class="body"><p>Returns the value of <i>BigNumber</i> as a base-16, <code class="inline">0x</code>-prefixed <a href="#/v5/api/utils/bytes/-%23-DataHexString">DataHexString</a>.</p>
|
||||
</div></div><div class="property show-anchors"><div class="signature"><span class="path">BigNumber</span><span class="symbol">.</span><span class="method">toHexString</span><span class="symbol">(</span> <span class="symbol">)</span> <span class="arrow">⇒</span> <span class="returns">string< <a href="#/v5/api/utils/bytes/-%23-DataHexString">DataHexString</a> ></span><div class="anchors"><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/bignumber/src.ts/bignumber.ts#L197">source</a></div></div><div class="body"><p>Returns the value of <i>BigNumber</i> as a base-16, <code class="inline">0x</code>-prefixed <a href="#/v5/api/utils/bytes/-%23-DataHexString">DataHexString</a>.</p>
|
||||
|
||||
</div></div><a name="/v5/api/utils/bignumber/-%23-BigNumber--BigNumber--methods--inspection"></a><a name="/v5/api/utils/bignumber/"></a><h3 class="show-anchors"><div>Inspection<div class="anchors"><a class="self" href="#/v5/api/utils/bignumber/-%23-BigNumber--BigNumber--methods--inspection"></a></div></div></h3>
|
||||
<div class="property show-anchors"><div class="signature"><span class="path">ethers</span><span class="symbol">.</span><span class="path">BigNumnber</span><span class="symbol">.</span><span class="method">isBigNumber</span><span class="symbol">(</span> <span class="param">object</span> <span class="symbol">)</span> <span class="arrow">⇒</span> <span class="returns">boolean</span><div class="anchors"><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/bignumber/src.ts/bignumber.ts#L246">source</a></div></div><div class="body"><p>Returns true if and only if the <i>object</i> is a BigNumber object.</p>
|
||||
<div class="property show-anchors"><div class="signature"><span class="path">ethers</span><span class="symbol">.</span><span class="path">BigNumnber</span><span class="symbol">.</span><span class="method">isBigNumber</span><span class="symbol">(</span> <span class="param">object</span> <span class="symbol">)</span> <span class="arrow">⇒</span> <span class="returns">boolean</span><div class="anchors"><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/bignumber/src.ts/bignumber.ts#L250">source</a></div></div><div class="body"><p>Returns true if and only if the <i>object</i> is a BigNumber object.</p>
|
||||
|
||||
</div></div><a name="/v5/api/utils/bignumber/-%23-BigNumber--BigNumber--methods--examples"></a><a name="/v5/api/utils/bignumber/"></a><h3 class="show-anchors"><div>Examples<div class="anchors"><a class="self" href="#/v5/api/utils/bignumber/-%23-BigNumber--BigNumber--methods--examples"></a></div></div></h3>
|
||||
<div class="code">let a = BigNumber.from(42);
|
||||
@@ -2104,20 +2106,20 @@ a.mul(b);
|
||||
</div></div><a name="/v5/api/utils/bytes/-%23-utils-shuffled"></a><div class="property show-anchors"><div class="signature"><span class="path">ethers</span><span class="symbol">.</span><span class="path">utils</span><span class="symbol">.</span><span class="method">shuffled</span><span class="symbol">(</span> <span class="param">array</span> <span class="symbol">)</span> <span class="arrow">⇒</span> <span class="returns">Array< any ></span><div class="anchors"><a class="self" href="#/v5/api/utils/bytes/-%23-utils-shuffled"></a><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/random/src.ts/shuffle.ts#L3">source</a></div></div><div class="body"><p>Return a copy of <i>array</i> shuffled using <a href="https://en.wikipedia.org/wiki/Fisher-Yates_shuffle">Fisher-Yates Shuffle</a>.</p>
|
||||
|
||||
</div></div><div class="code-title"><div>Examples</div></div><div class="code">utils.randomBytes(8)
|
||||
<span class="result ok">// Uint8Array [ 95, 9, 0, 81, 176, 49, 211, 225 ]
|
||||
<span class="result ok">// Uint8Array [ 158, 14, 185, 6, 8, 37, 214, 172 ]
|
||||
</span>
|
||||
const data = [ 1, 2, 3, 4, 5, 6, 7 ];
|
||||
|
||||
<span class="comment">// Returns a new Array
|
||||
</span>utils.shuffled(data);
|
||||
<span class="result ok">// [
|
||||
</span><span class="result ok">// 6,
|
||||
</span><span class="result ok">// 7,
|
||||
</span><span class="result ok">// 4,
|
||||
</span><span class="result ok">// 3,
|
||||
</span><span class="result ok">// 5,
|
||||
</span><span class="result ok">// 1,
|
||||
</span><span class="result ok">// 2
|
||||
</span><span class="result ok">// 3,
|
||||
</span><span class="result ok">// 4,
|
||||
</span><span class="result ok">// 7,
|
||||
</span><span class="result ok">// 2,
|
||||
</span><span class="result ok">// 5,
|
||||
</span><span class="result ok">// 6
|
||||
</span><span class="result ok">// ]
|
||||
</span>
|
||||
<span class="comment">// The Original is unscathed...
|
||||
@@ -3643,7 +3645,7 @@ interface.events.Transfer.decode(data, topics)
|
||||
|
||||
<span class="comment">// v5
|
||||
</span>interface.encodeFilterTopics("Transfer", values)
|
||||
interface.encodeEventLog("Transfer", data, topics)
|
||||
interface.decodeEventLog("Transfer", data, topics)
|
||||
</div><a name="/v5/migration/ethers-v4/-%23-migration-v4--interface--inspection"></a><a name="/v5/migration/ethers-v4/"></a><h3 class="show-anchors"><div>Inspection<div class="anchors"><a class="self" href="#/v5/migration/ethers-v4/-%23-migration-v4--interface--inspection"></a></div></div></h3><p>Interrogating properties about a function or event can now (mostly) be done directly on the <a href="#/v5/api/utils/abi/fragments/-%23-Fragment">Fragment</a> object.</p>
|
||||
|
||||
<div class="code">// v4
|
||||
@@ -4044,7 +4046,7 @@ $bottom: This just represents an example of
|
||||
<div class="nav previous"><!--PREV_LINK--></div>
|
||||
<div class="nav next"><!--NEXT_LINK--></div>
|
||||
</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 3, 2020, 1:44am.</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 5, 2020, 12:0am.</div>
|
||||
</div>
|
||||
<script src="/v5/static/script.js" type="text/javascript"></script>
|
||||
</body>
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
<div class="nav previous"><a href="/v5/migration/ethers-v4/"><span class="arrow">←</span>Migration: From Ethers v4</a></div>
|
||||
<div class="nav next"><a href="/v5/contributing/">Contributing and Hacking<span class="arrow">→</span></a></div>
|
||||
</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 3, 2020, 1:44am.</div>
|
||||
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on July 5, 2020, 12:0am.</div>
|
||||
</div>
|
||||
<script src="/v5/static/script.js" type="text/javascript"></script>
|
||||
</body>
|
||||
|
||||
@@ -15,10 +15,28 @@ module.exports = function(config) {
|
||||
],
|
||||
port: 9876,
|
||||
logLevel: config.LOG_INFO,
|
||||
browsers: [ 'ChromeHeadless' ],
|
||||
browsers: [ 'ChromeHeadless', "HeadlessLittleLiar" ],
|
||||
autoWatch: false,
|
||||
singleRun: true,
|
||||
browserNoActivityTimeout: 60000
|
||||
browserNoActivityTimeout: 60000,
|
||||
customLaunchers: {
|
||||
HeadlessLittleLiar: {
|
||||
base: 'ChromeHeadless',
|
||||
// https://peter.sh/experiments/chromium-command-line-switches/
|
||||
flags: [
|
||||
'--disable-extensions',
|
||||
|
||||
// Enable this to help debug CORS issues (otherwise fetch throws a useless TypeError)
|
||||
//'--disable-web-security',
|
||||
|
||||
'--enable-automation',
|
||||
|
||||
// Cloudflare will block (on the testnet endpoints) any traffic
|
||||
// from a headless chome (based on the user agent), so we lie
|
||||
// This was take from Safari, because that is what I had on-hand
|
||||
'--user-agent', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.1 Safari/605.1.15']
|
||||
}
|
||||
},
|
||||
/*
|
||||
client: {
|
||||
mocha: {
|
||||
|
||||
@@ -15,14 +15,33 @@ module.exports = function(config) {
|
||||
],
|
||||
port: 9876,
|
||||
logLevel: config.LOG_INFO,
|
||||
browsers: [ 'ChromeHeadless' ],
|
||||
browsers: [ 'ChromeHeadless', "HeadlessLittleLiar" ],
|
||||
autoWatch: false,
|
||||
singleRun: true,
|
||||
browserNoActivityTimeout: 600000
|
||||
browserNoActivityTimeout: 600000,
|
||||
|
||||
customLaunchers: {
|
||||
HeadlessLittleLiar: {
|
||||
base: 'ChromeHeadless',
|
||||
// https://peter.sh/experiments/chromium-command-line-switches/
|
||||
flags: [
|
||||
'--disable-extensions',
|
||||
|
||||
// Enable this to help debug CORS issues (otherwise fetch throws a useless TypeError)
|
||||
//'--disable-web-security',
|
||||
|
||||
'--enable-automation',
|
||||
|
||||
// Cloudflare will block (on the testnet endpoints) any traffic
|
||||
// from a headless chome (based on the user agent), so we lie
|
||||
// This was take from Safari, because that is what I had on-hand
|
||||
'--user-agent', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.1 Safari/605.1.15']
|
||||
}
|
||||
},
|
||||
/*
|
||||
client: {
|
||||
mocha: {
|
||||
grep: 'utf',
|
||||
grep: 'Etherscan',
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
6
misc/ReactNativeTestApp/.buckconfig
Normal file
6
misc/ReactNativeTestApp/.buckconfig
Normal file
@@ -0,0 +1,6 @@
|
||||
|
||||
[android]
|
||||
target = Google Inc.:Google APIs:23
|
||||
|
||||
[maven_repositories]
|
||||
central = https://repo1.maven.org/maven2
|
||||
4
misc/ReactNativeTestApp/.eslintrc.js
Normal file
4
misc/ReactNativeTestApp/.eslintrc.js
Normal file
@@ -0,0 +1,4 @@
|
||||
module.exports = {
|
||||
root: true,
|
||||
extends: '@react-native-community',
|
||||
};
|
||||
73
misc/ReactNativeTestApp/.flowconfig
Normal file
73
misc/ReactNativeTestApp/.flowconfig
Normal file
@@ -0,0 +1,73 @@
|
||||
[ignore]
|
||||
; We fork some components by platform
|
||||
.*/*[.]android.js
|
||||
|
||||
; Ignore "BUCK" generated dirs
|
||||
<PROJECT_ROOT>/\.buckd/
|
||||
|
||||
; Ignore polyfills
|
||||
node_modules/react-native/Libraries/polyfills/.*
|
||||
|
||||
; These should not be required directly
|
||||
; require from fbjs/lib instead: require('fbjs/lib/warning')
|
||||
node_modules/warning/.*
|
||||
|
||||
; Flow doesn't support platforms
|
||||
.*/Libraries/Utilities/LoadingView.js
|
||||
|
||||
[untyped]
|
||||
.*/node_modules/@react-native-community/cli/.*/.*
|
||||
|
||||
[include]
|
||||
|
||||
[libs]
|
||||
node_modules/react-native/interface.js
|
||||
node_modules/react-native/flow/
|
||||
|
||||
[options]
|
||||
emoji=true
|
||||
|
||||
esproposal.optional_chaining=enable
|
||||
esproposal.nullish_coalescing=enable
|
||||
|
||||
module.file_ext=.js
|
||||
module.file_ext=.json
|
||||
module.file_ext=.ios.js
|
||||
|
||||
munge_underscores=true
|
||||
|
||||
module.name_mapper='^react-native/\(.*\)$' -> '<PROJECT_ROOT>/node_modules/react-native/\1'
|
||||
module.name_mapper='^@?[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> '<PROJECT_ROOT>/node_modules/react-native/Libraries/Image/RelativeImageStub'
|
||||
|
||||
suppress_type=$FlowIssue
|
||||
suppress_type=$FlowFixMe
|
||||
suppress_type=$FlowFixMeProps
|
||||
suppress_type=$FlowFixMeState
|
||||
|
||||
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)
|
||||
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)?:? #[0-9]+
|
||||
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError
|
||||
|
||||
[lints]
|
||||
sketchy-null-number=warn
|
||||
sketchy-null-mixed=warn
|
||||
sketchy-number=warn
|
||||
untyped-type-import=warn
|
||||
nonstrict-import=warn
|
||||
deprecated-type=warn
|
||||
unsafe-getters-setters=warn
|
||||
unnecessary-invariant=warn
|
||||
signature-verification-failure=warn
|
||||
deprecated-utility=error
|
||||
|
||||
[strict]
|
||||
deprecated-type
|
||||
nonstrict-import
|
||||
sketchy-null
|
||||
unclear-type
|
||||
unsafe-getters-setters
|
||||
untyped-import
|
||||
untyped-type-import
|
||||
|
||||
[version]
|
||||
^0.122.0
|
||||
1
misc/ReactNativeTestApp/.gitattributes
vendored
Normal file
1
misc/ReactNativeTestApp/.gitattributes
vendored
Normal file
@@ -0,0 +1 @@
|
||||
*.pbxproj -text
|
||||
61
misc/ReactNativeTestApp/.gitignore
vendored
Normal file
61
misc/ReactNativeTestApp/.gitignore
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
# OSX
|
||||
#
|
||||
.DS_Store
|
||||
|
||||
# Xcode
|
||||
#
|
||||
build/
|
||||
*.pbxuser
|
||||
!default.pbxuser
|
||||
*.mode1v3
|
||||
!default.mode1v3
|
||||
*.mode2v3
|
||||
!default.mode2v3
|
||||
*.perspectivev3
|
||||
!default.perspectivev3
|
||||
xcuserdata
|
||||
*.xccheckout
|
||||
*.moved-aside
|
||||
DerivedData
|
||||
*.hmap
|
||||
*.ipa
|
||||
*.xcuserstate
|
||||
|
||||
# Android/IntelliJ
|
||||
#
|
||||
build/
|
||||
.idea
|
||||
.gradle
|
||||
local.properties
|
||||
*.iml
|
||||
|
||||
# node.js
|
||||
#
|
||||
node_modules/
|
||||
npm-debug.log
|
||||
yarn-error.log
|
||||
|
||||
# BUCK
|
||||
buck-out/
|
||||
\.buckd/
|
||||
*.keystore
|
||||
!debug.keystore
|
||||
|
||||
# fastlane
|
||||
#
|
||||
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
|
||||
# screenshots whenever they are needed.
|
||||
# For more information about the recommended setup visit:
|
||||
# https://docs.fastlane.tools/best-practices/source-control/
|
||||
|
||||
*/fastlane/report.xml
|
||||
*/fastlane/Preview.html
|
||||
*/fastlane/screenshots
|
||||
|
||||
# Bundle artifact
|
||||
*.jsbundle
|
||||
|
||||
# CocoaPods
|
||||
/ios/Pods/
|
||||
|
||||
webserver.log
|
||||
6
misc/ReactNativeTestApp/.prettierrc.js
Normal file
6
misc/ReactNativeTestApp/.prettierrc.js
Normal file
@@ -0,0 +1,6 @@
|
||||
module.exports = {
|
||||
bracketSpacing: false,
|
||||
jsxBracketSameLine: true,
|
||||
singleQuote: true,
|
||||
trailingComma: 'all',
|
||||
};
|
||||
1
misc/ReactNativeTestApp/.watchmanconfig
Normal file
1
misc/ReactNativeTestApp/.watchmanconfig
Normal file
@@ -0,0 +1 @@
|
||||
{}
|
||||
98
misc/ReactNativeTestApp/App.js
Normal file
98
misc/ReactNativeTestApp/App.js
Normal file
@@ -0,0 +1,98 @@
|
||||
/**
|
||||
* Sample React Native App
|
||||
* https://github.com/facebook/react-native
|
||||
*
|
||||
* @format
|
||||
* @flow strict-local
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import {
|
||||
SafeAreaView,
|
||||
StyleSheet,
|
||||
ScrollView,
|
||||
View,
|
||||
Text,
|
||||
StatusBar
|
||||
} from 'react-native';
|
||||
|
||||
import {
|
||||
Colors
|
||||
} from 'react-native/Libraries/NewAppScreen';
|
||||
|
||||
|
||||
|
||||
// Inject the crpyot shims (BEFORE the ethers shims)
|
||||
import "./crypto-shims.js";
|
||||
|
||||
// Inject the missing features with the ethers shims
|
||||
import "./libs/shims.js";
|
||||
|
||||
// Import ethers
|
||||
import { ethers } from "./libs/ethers.js";
|
||||
|
||||
// Import the test framework
|
||||
import "./libs/mocha.js";
|
||||
|
||||
// Setup up a testing context (injects primitives like `describe` and `it`)
|
||||
mocha.setup({ ui: "bdd" });
|
||||
|
||||
setTimeout(async function() {
|
||||
|
||||
// Mock location (Mocha checks this?)
|
||||
if (window.location == null) {
|
||||
window.location = {
|
||||
search: ""
|
||||
};
|
||||
}
|
||||
|
||||
// Load the test cases
|
||||
const testing = await import("./libs/tests.js");
|
||||
|
||||
// Serialize all writes to the logging server
|
||||
let inflight = Promise.resolve();
|
||||
testing.setLogFunc(function(message) {
|
||||
console.log(message);
|
||||
inflight = inflight.then(() => {
|
||||
return ethers.utils._fetchData("http:/\/localhost:8042/", ethers.utils.toUtf8Bytes(message)).then((result) => {
|
||||
return true;
|
||||
}, (error) => {
|
||||
return false;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
mocha.reporter(testing.Reporter);
|
||||
|
||||
//mocha.grep(new RegExp("Test nameprep")).run()
|
||||
mocha.run();
|
||||
}, 1000);
|
||||
|
||||
|
||||
const App: () => React$Node = () => {
|
||||
return (
|
||||
<>
|
||||
<StatusBar barStyle="dark-content" />
|
||||
<SafeAreaView>
|
||||
<ScrollView
|
||||
contentInsetAdjustmentBehavior="automatic"
|
||||
style={styles.scrollView}>
|
||||
<View>
|
||||
<Text>Running Tests</Text>
|
||||
</View>
|
||||
</ScrollView>
|
||||
</SafeAreaView>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
scrollView: {
|
||||
backgroundColor: Colors.lighter,
|
||||
},
|
||||
body: {
|
||||
backgroundColor: Colors.white,
|
||||
},
|
||||
});
|
||||
|
||||
export default App;
|
||||
14
misc/ReactNativeTestApp/__tests__/App-test.js
Normal file
14
misc/ReactNativeTestApp/__tests__/App-test.js
Normal file
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* @format
|
||||
*/
|
||||
|
||||
import 'react-native';
|
||||
import React from 'react';
|
||||
import App from '../App';
|
||||
|
||||
// Note: test renderer must be required after react-native.
|
||||
import renderer from 'react-test-renderer';
|
||||
|
||||
it('renders correctly', () => {
|
||||
renderer.create(<App />);
|
||||
});
|
||||
55
misc/ReactNativeTestApp/android/app/_BUCK
Normal file
55
misc/ReactNativeTestApp/android/app/_BUCK
Normal file
@@ -0,0 +1,55 @@
|
||||
# To learn about Buck see [Docs](https://buckbuild.com/).
|
||||
# To run your application with Buck:
|
||||
# - install Buck
|
||||
# - `npm start` - to start the packager
|
||||
# - `cd android`
|
||||
# - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"`
|
||||
# - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck
|
||||
# - `buck install -r android/app` - compile, install and run application
|
||||
#
|
||||
|
||||
load(":build_defs.bzl", "create_aar_targets", "create_jar_targets")
|
||||
|
||||
lib_deps = []
|
||||
|
||||
create_aar_targets(glob(["libs/*.aar"]))
|
||||
|
||||
create_jar_targets(glob(["libs/*.jar"]))
|
||||
|
||||
android_library(
|
||||
name = "all-libs",
|
||||
exported_deps = lib_deps,
|
||||
)
|
||||
|
||||
android_library(
|
||||
name = "app-code",
|
||||
srcs = glob([
|
||||
"src/main/java/**/*.java",
|
||||
]),
|
||||
deps = [
|
||||
":all-libs",
|
||||
":build_config",
|
||||
":res",
|
||||
],
|
||||
)
|
||||
|
||||
android_build_config(
|
||||
name = "build_config",
|
||||
package = "com.reactnativetestapp",
|
||||
)
|
||||
|
||||
android_resource(
|
||||
name = "res",
|
||||
package = "com.reactnativetestapp",
|
||||
res = "src/main/res",
|
||||
)
|
||||
|
||||
android_binary(
|
||||
name = "app",
|
||||
keystore = "//android/keystores:debug",
|
||||
manifest = "src/main/AndroidManifest.xml",
|
||||
package_type = "debug",
|
||||
deps = [
|
||||
":app-code",
|
||||
],
|
||||
)
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user