Compare commits

...

50 Commits

Author SHA1 Message Date
Richard Moore
5aefb4303d Fix for HID on ES2015; does not support dymanic imports (#798). 2020-04-25 03:46:46 -04:00
Richard Moore
d1f3a42c11 Minor typing-detected fixes. 2020-04-25 03:26:44 -04:00
Richard Moore
bda6623091 Added initial support for recoverable coding erros (#800). 2020-04-25 03:25:42 -04:00
Richard Moore
14e6811bf7 More draconian Typing. 2020-04-25 01:06:28 -04:00
Richard Moore
2e24920d02 Omit HID libraries for hardware-wallets package on unsupported environments (#798). 2020-04-24 18:22:06 -04:00
Richard Moore
017ea0d6bd Make default constructor non-payable (#684). 2020-04-24 03:02:57 -04:00
Richard Moore
47e4655f6b Updated dist files. 2020-04-23 23:35:39 -04:00
Richard Moore
8e7751f7df Fixed inconsistent log format in WebSocketProvider (#795). 2020-04-23 23:17:55 -04:00
Richard Moore
6707754580 Added WebSocketProvider support for ENS names in filters. 2020-04-23 23:10:21 -04:00
Richard Moore
aeeb75f74c Fixed provider filtering by ENS name. 2020-04-23 22:54:25 -04:00
Richard Moore
8bb2a0fd08 Fixed ContractFactory.deploy ignoring overrides (#796). 2020-04-23 22:28:51 -04:00
Richard Moore
13862589fa Re-enable Cloudflare tests; seems to be back up. 2020-04-23 08:16:25 -04:00
Richard Moore
fca5ccbc20 Fix median calculation for large block number deltas across FallbackProvider backends. 2020-04-23 08:15:46 -04:00
Richard Moore
8cf4b3cf45 Work-around for Cloudflare not offering eth_blockNumber. 2020-04-23 08:13:53 -04:00
Richard Moore
71d03c6e3c Added string spell-checking to library and fixed discovered typos. 2020-04-22 02:42:25 -04:00
Richard Moore
2aeb4e9a9c Moved all flatworm docs to inline code. 2020-04-19 02:18:20 -04:00
Richard Moore
9712592090 Removed external code filies in docs. 2020-04-19 02:17:02 -04:00
Richard Moore
9b3f4dfdac Sync GitHub issue cache. 2020-04-18 06:41:34 -04:00
Richard Moore
db604aa6af Updated dist files. 2020-04-18 06:40:36 -04:00
Richard Moore
560adeabb0 Fixed getUrl for node 8. 2020-04-18 06:32:35 -04:00
Richard Moore
25102d4009 Updates for dist builds. 2020-04-18 05:44:51 -04:00
Richard Moore
3135d7ff6c Added updated admin scripts needed for dist build (#789). 2020-04-18 05:23:36 -04:00
Richard Moore
4874419119 Updated dist files. 2020-04-18 05:14:55 -04:00
Richard Moore
da3b0bf078 Dependency security updates. 2020-04-18 02:56:19 -04:00
Richard Moore
9ae6b70efb Fixes for dist builds without injected XMLHttpRequest (#789, #506). 2020-04-18 02:46:52 -04:00
Richard Moore
723249d36c Added documentation. 2020-04-16 22:25:05 -04:00
Richard Moore
5b51549437 Added npmignore for asm package. 2020-04-16 22:01:49 -04:00
Richard Moore
2f30410ddd Updated dist files. 2020-04-16 21:59:53 -04:00
Richard Moore
798cafa6fe Added all test environments back to CI. 2020-04-16 21:33:50 -04:00
Richard Moore
cc72f76695 Added support for Contract event parsing error recovery. 2020-04-16 21:33:24 -04:00
Richard Moore
4ef0e4f765 Fix provider log filters with zero topics (#785). 2020-04-16 21:30:35 -04:00
Richard Moore
51e198aee1 Attempting to fix ESM chrome-upgrade task. 2020-04-15 19:28:50 -04:00
Richard Moore
54dfaacba3 Updated dist files. 2020-04-15 18:28:04 -04:00
Richard Moore
797abb7267 Temporarily remove CloudflareProvider tests; it is down and breaking the tests. 2020-04-15 18:11:39 -04:00
Richard Moore
39c78f37ce Fixed Contract filter never unsubscribing. 2020-04-15 18:09:38 -04:00
Richard Moore
284771ea39 Updated ABI Number coder for BigNumber API change. 2020-04-15 16:49:55 -04:00
Richard Moore
7dcefcbf71 Better error reporting for Fragments. 2020-04-15 16:49:03 -04:00
Richard Moore
2eb3823de4 Fixed early Contract filter unsubscribing. 2020-04-15 16:47:55 -04:00
Richard Moore
69f707762e Fixed WebSocketProvider filter events (#784). 2020-04-15 16:46:15 -04:00
Richard Moore
7498c18235 Added bitwise operations to BigNumber (#781). 2020-04-15 15:39:26 -04:00
Richard Moore
220e0710a9 Fixed typo in changelog. 2020-04-03 22:16:39 -04:00
Richard Moore
40fb8b5b5c Updated dist files. 2020-04-03 22:13:06 -04:00
Richard Moore
8ad26f0ff4 Removed transactionLogIndex from tests (#415). 2020-04-03 22:03:51 -04:00
Richard Moore
d7c8b355a0 Fix stateMutability calculation for constructors (#762). 2020-04-03 22:01:33 -04:00
Richard Moore
6caf7c292c Correctly return the Provider in NonceManager. 2020-04-03 21:33:56 -04:00
Richard Moore
2882546351 Fail earlier when resolving an ENS name that is not a string. 2020-04-03 21:32:44 -04:00
Richard Moore
6526de016f Fixed mutabilityState calculation for function fragments (#762). 2020-04-03 21:28:53 -04:00
Richard Moore
da412f6607 Force Log properties to be non-optional (#415). 2020-04-03 20:45:23 -04:00
Richard Moore
053a2d7fcd Fixed Signer call not forwarding blockTag (#768). 2020-04-03 18:41:24 -04:00
Richard Moore
a656079752 Updated dist files. 2020-03-31 23:40:54 -04:00
1163 changed files with 6755 additions and 7789 deletions

View File

@@ -29,7 +29,7 @@ commands:
command: |
sudo apt-get purge chromium-browser
sudo apt-get update
sudo apt-get install -y libappindicator1 fonts-liberation
sudo apt-get install -y libappindicator1 fonts-liberation libgbm1
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo dpkg -i google-chrome*.deb
google-chrome --version

View File

@@ -3,6 +3,51 @@ Changelog
This change log is managed by `scripts/cmds/update-versions` but may be manually updated.
ethers/v5.0.0-beta.183 (2020-04-23 23:28)
-----------------------------------------
- Fixed inconsistent log format in WebSocketProvider. ([#795](https://github.com/ethers-io/ethers.js/issues/795); [8e7751f](https://github.com/ethers-io/ethers.js/commit/8e7751f7dfb41e58f81c7918cf36c152c3209ae2))
- Added WebSocketProvider support for ENS names in filters. ([6707754](https://github.com/ethers-io/ethers.js/commit/6707754580490c5a801d6205af0841794d20b3c9))
- Fixed provider filtering by ENS name. ([aeeb75f](https://github.com/ethers-io/ethers.js/commit/aeeb75f74c3be11b9b3b2925fd73349070542e54))
- Fixed ContractFactory.deploy ignoring overrides. ([#796](https://github.com/ethers-io/ethers.js/issues/796); [8bb2a0f](https://github.com/ethers-io/ethers.js/commit/8bb2a0fd08f6f128a80444e3fd90c29e4cd7edfb))
- Fix median calculation for large block number deltas across FallbackProvider backends. ([fca5ccb](https://github.com/ethers-io/ethers.js/commit/fca5ccbc2052569e700a96dbb1de1c9cef7c966f))
- Work-around for Cloudflare not offering eth_blockNumber. ([8cf4b3c](https://github.com/ethers-io/ethers.js/commit/8cf4b3cf4598f4f3643d5ebe9c366466d398cb83))
- Added string spell-checking to library and fixed discovered typos. ([71d03c6](https://github.com/ethers-io/ethers.js/commit/71d03c6e3cab1aacb3e4e74d3966fbaa7db2ee06))
- Fixed getUrl for node 8. ([560adea](https://github.com/ethers-io/ethers.js/commit/560adeabb06a2ab483bcad162f02ccef41ebc245))
- Dependency security updates. ([da3b0bf](https://github.com/ethers-io/ethers.js/commit/da3b0bf0786fe8a95c68485d130ca59c597ffe4d))
- Fixes for dist builds without injected XMLHttpRequest. ([#789](https://github.com/ethers-io/ethers.js/issues/789), [#506](https://github.com/ethers-io/ethers.js/issues/506); [9ae6b70](https://github.com/ethers-io/ethers.js/commit/9ae6b70efb9f3d3251820403597085cfa30ace05))
ethers/v5.0.0-beta.182 (2020-04-16 21:53)
-----------------------------------------
- Added support for Contract event parsing error recovery. ([cc72f76](https://github.com/ethers-io/ethers.js/commit/cc72f76695572d235d7f5a5ad4dc1838a5fe884a))
- Fix provider log filters with zero topics. ([#785](https://github.com/ethers-io/ethers.js/issues/785); [4ef0e4f](https://github.com/ethers-io/ethers.js/commit/4ef0e4f7653226bf8cca86e065ad614e7288af96))
ethers/v5.0.0-beta.181 (2020-04-15 18:23)
-----------------------------------------
- Temporarily remove CloudflareProvider tests; it is down and breaking the tests. ([797abb7](https://github.com/ethers-io/ethers.js/commit/797abb726711499d96bf1c12c61e3bb1a7b4925d))
- Better error reporting for Fragments. ([7dcefcb](https://github.com/ethers-io/ethers.js/commit/7dcefcbf71ef337103639bbe3f4ad2625565651a))
- Fixed Contract filter unsubscribing. ([2eb3823](https://github.com/ethers-io/ethers.js/commit/2eb3823de4ba111cc0c746a0715fe6dd3d1b16da), [39c78f3](https://github.com/ethers-io/ethers.js/commit/39c78f37ceff9b8ec08329903dcba7bd53bd8661))
- Fixed WebSocketProvider filter events. ([#784](https://github.com/ethers-io/ethers.js/issues/784); [69f7077](https://github.com/ethers-io/ethers.js/commit/69f707762ed5939c5f52bf6dce5c5513aaf6fa1d))
- Added bitwise operations to BigNumber. ([#781](https://github.com/ethers-io/ethers.js/issues/781); [7498c18](https://github.com/ethers-io/ethers.js/commit/7498c18235c7566b2f652cddba991f55e0943da8), [284771e](https://github.com/ethers-io/ethers.js/commit/284771ea39b6f4ee9cdf75ce5feea9e6aa9a65c5))
ethers/v5.0.0-beta.180 (2020-04-03 22:10)
-----------------------------------------
- Correctly return the Provider in NonceManager. ([6caf7c2](https://github.com/ethers-io/ethers.js/commit/6caf7c292cd5f03741cd6b30053c3325c4f30a81))
- Fail earlier when resolving an ENS name that is not a string. ([2882546](https://github.com/ethers-io/ethers.js/commit/28825463517f8821392464ec2283ee59c431d928))
- Fixed mutabilityState calculation for function fragments. ([#762](https://github.com/ethers-io/ethers.js/issues/762); [6526de0](https://github.com/ethers-io/ethers.js/commit/6526de016fda5403474dad61ee59acc62ee25ebc), [d7c8b35](https://github.com/ethers-io/ethers.js/commit/d7c8b355a049b36068b0525a357c6278639a8d58))
- Force Log properties to be non-optional. ([#415](https://github.com/ethers-io/ethers.js/issues/415); [da412f6](https://github.com/ethers-io/ethers.js/commit/da412f660723d1c411484e74970ce4eb166374c2), [8ad26f0](https://github.com/ethers-io/ethers.js/commit/8ad26f0ff42614a6c40e735cb6fffd36874da1a0))
- Fixed Signer call not forwarding blockTag. ([#768](https://github.com/ethers-io/ethers.js/issues/768); [053a2d7](https://github.com/ethers-io/ethers.js/commit/053a2d7fcdb4ca4c9bfd0bee0f42e0187d3db477))
ethers/v5.0.0-beta.179 (2020-03-31 23:40)
-----------------------------------------
- Fixed ENS CLI lookup for Website. ([0f144c6](https://github.com/ethers-io/ethers.js/commit/0f144c6cc03082026080782356b940af3389b34e))
- Fixed getEtherPrice for EtherscanProvider. ([#776](https://github.com/ethers-io/ethers.js/issues/776); [6c71b51](https://github.com/ethers-io/ethers.js/commit/6c71b515126d8ef3cea5a1aec814c4cab56cc1a5))
- Fixed ENS CLI tool set-websites and added set-name. ([70cffb6](https://github.com/ethers-io/ethers.js/commit/70cffb6a5166a79a54e02b03b6a7ec0085407e07))
ethers/v5.0.0-beta.178 (2020-03-30 22:14)
-----------------------------------------

View File

@@ -49,13 +49,6 @@ function run(progname, args, ignoreErrorStream) {
}
function setupConfig(outDir, moduleType, targetType) {
function update(value) {
let comps = value.split("/");
if (comps.length >= 3 && comps[0] === "." && comps[1].match(/^lib(\.esm)?$/)) {
return outDir + comps.slice(2).join("/");
}
return value;
}
// Configure the tsconfit.package.json...
const path = resolve(__dirname, "../tsconfig.package.json");
@@ -64,22 +57,24 @@ function setupConfig(outDir, moduleType, targetType) {
content.compilerOptions.target = targetType;
saveJson(path, content);
// Configure the browser field for every pacakge, copying the
// browser.umd filed for UMD and browser.esm for ESM
dirnames.forEach((dirname) => {
let info = loadPackage(dirname);
if (info._ethers_nobuild) { return; }
[ "browser", "_browser" ].forEach((key) => {
if (info[key]) {
if (typeof(info[key]) === "string") {
info[key] = update(info[key]);
} else {
for (let k in info[key]) {
info[key][k] = update(info[key][k]);
}
}
if (targetType === "es2015") {
if (info["browser.esm"]) {
info.browser = info["browser.esm"];
}
});
} else if (targetType === "es5") {
if (info["browser.umd"]) {
info.browser = info["browser.umd"];
}
} else {
throw new Error("unsupported target");
}
savePackage(dirname, info);
let path = resolve(__dirname, "../packages", dirname, "tsconfig.json");

View File

@@ -108,7 +108,7 @@ if (process.argv.length > 2) {
// Publish the release
const link = await createRelease(username, password, change.version, change.title, change.content, beta);
log(`<bold:Published Release:> ${ link }...`);
log(`<bold:Published Release:> ${ link }`);
}
})();

View File

@@ -4,39 +4,32 @@ const { loadPackage, savePackage } = require("../local");
const arg = process.argv[2];
(async function() {
switch(arg) {
case "esm":
setupBuild(true);
break;
process.argv.slice(2).forEach((arg) => {
console.log("Setting Option:", arg);
switch(arg) {
case "esm":
setupBuild(true);
break;
case "cjs":
setupBuild(false);
break;
case "cjs":
setupBuild(false);
break;
case "browser-lang-en": {
const info = loadPackage("wordlists");
if (info._browser) {
info.browser = info._browser;
delete info._browser;
savePackage("wordlists", info);
}
break;
}
case "browser-lang-all": {
const info = loadPackage("wordlists");
if (info.browser) {
info._browser = info.browser;
// This will remove the browser field entirely, so make sure
// to set esm of cjs first as they will restore the browser
// field
case "browser-lang-all": {
const info = loadPackage("wordlists");
delete info.browser;
savePackage("wordlists", info);
break;
}
break;
}
default:
console.log("unknown option");
return 1;
}
default:
console.log("Unknown option:", arg);
return 1;
}
});
return 0;
})().then((result) => {

213
admin/cmds/spell-check.js Normal file
View File

@@ -0,0 +1,213 @@
"use strict";
const { resolve } = require("path");
const fs = require("fs");
const Words = fs.readFileSync("/usr/share/dict/words").toString().split("\n").reduce((accum, word) => {
accum[word.toLowerCase()] = true;
return accum;
}, { });
`
// Words missing from the dictionary
addresses aligned autofill called cancelled censored compiled
computed configured consumed creating decoded
decoding decrypt decrypted decrypting deployed deploying deprecated
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
named nested neutered numeric offline optimizer owned packed padded parsed parsing
passed placeholder processing reached recommended recovered redacted remaining replaced
required serializes shared signed signing stored supported
tagging targetted transactions uninstall unsubscribe using verifies website
// Overly Specific Words
BIP BIP39 BIP44 crypto eip hashes hmac icap
keccak namehash ripemd RLP scrypt secp sha
blockhash
bitcoin ethereum finney gwei kwei mwei satoshi szabo wei weth
crowdsale hexlify hd hdnode underpriced
boolean int struct tuple uint
nonpayable
jumpdest mstore shr shl xor
// Classes
ABIEncoder testcase numberish Wordlist
// Common Code Strings
abi addr api app arg arrayify asm basex
bigint bn byte bytecode callback
calldata checksum ciphertext cli codepoint
config contenthash ctr ctrl debug 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
multihash nfc nfkc
nfd nfkd nodehash 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 zlib
// AbiV2
abiv
// Query parameters
apikey asc endblock startblock
Cloudflare Etherscan INFURA IPFS 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
// nameprep tags
ALCat BiDi LCat nameprep
// Lanauge Codes (and short binary data)
cn cz en es fr it ja tw zh zh_cn zh_tw
OYAa IJBEJqXZJ
`.split("\n").filter((l) => (l.substring(0, 2) != "/\/")).join("\n").split(/\s+/g,).forEach((word) => {
word = word.trim();
if (word === "") { return; }
Words[word.toLowerCase()] = true;
});
const ts = require("typescript");
function getStrings(source) {
const sourceFile = ts.createSourceFile("filename.ts", source);
const result = [ ];
function add(value, pos) {
const lineNo = sourceFile.getLineAndCharacterOfPosition(pos).line + 1;
result.push({ value, lineNo });
}
let lastClass = null, lastEnum = null;
function visit(node, depth) {
switch (node.kind) {
//case ts.SyntaxKind.TemplateExpression:
// if (node.head) { visit(node.head); }
// console.dir(node, { depth: null });
// break;
case ts.SyntaxKind.TemplateHead:
case ts.SyntaxKind.TemplateMiddle:
case ts.SyntaxKind.TemplateTail:
case ts.SyntaxKind.StringLiteral:
case ts.SyntaxKind.NoSubstitutionTemplateLiteral:
add(node.text, node.pos);
break;
}
ts.forEachChild(node, (node) => { return visit(node, depth + 1); });
}
visit(sourceFile, 0);
return result;
}
const Include = new RegExp("packages/.*/src.ts/.*\.ts$");
const Exclude = new RegExp("/node_modules/|src.ts/.*browser.*");
function getAllStrings(path) {
const Root = resolve(__dirname, path);
const readdir = function(path) {
if (path.match(Exclude)) { return [ ]; }
const stat = fs.statSync(path);
if (stat.isDirectory()) {
return fs.readdirSync(path).reduce((result, filename) => {
readdir(resolve(path, filename)).forEach((file) => {
result.push(file);
});
return result;
}, [ ]);
}
if (path.match(Include)) {
const source = fs.readFileSync(path).toString();
return [ { filename: path.substring(Root.length), values: getStrings(source) } ]
}
return [ ];
}
return readdir(Root);
}
function checkWord(word) {
word = word.toLowerCase();
// A word
if (Words[word]) { return true; }
// Simple Plural
if (word.match(/.*s$/) && Words[word.substring(0, word.length - 1)]) { return true; }
// Hex string
if (word.match(/^(0x)?[0-9a-f]*$/i)) { return true; }
}
function starts(text, prefix) {
return (text.substring(0, prefix.length) === prefix);
}
(async function() {
let count = 0;
getAllStrings(resolve(__dirname, "../../packages")).forEach((file) => {
if (starts(file.filename, "/testcases/src.ts/generation-scripts")) { return; }
if (starts(file.filename, "/asm/src.ts/opcodes.ts")) { return; }
file.values.forEach((entry) => {
function problem(word) {
count++;
console.log({
filename: file.filename,
word: JSON.stringify(word),
sentence: JSON.stringify(entry.value.substring(0, 80)),
line: entry.lineNo
});
}
const value = entry.value.trim();
// Emptry space
if (value === "") { return; }
// Prolly a require
if (value.match(/^@ethersproject\/[a-z0-9-]+$/)) { return; }
if (value.substring(0, 2) === "./") { return; }
// Prolly encoded binary data
if (value.indexOf(" ") === -1 && value.length > 20) { return; }
if (checkWord(value)) { return; }
value.replace(/([a-z+])([A-Z])/g, (all, first, secondLetter) => {
return first + " " + secondLetter;
}).replace(/((?:0x)?[A-Za-z]+)/gi, (all, word) => {
if (checkWord(word)) { return; }
problem(word);
return "";
});;
});
});
if (count) {
console.log(`Found ${ count } typos.`);
process.exit(1)
}
process.exit(0)
})();

View File

@@ -107,7 +107,7 @@ async function fetchGitHub(user, password, url, cacheOnly) {
async function _getIssues(user, password) {
const cacheOnly = (user == null);
let issues = await fetchGitHub(user, password, "https://api.github.com/repos/ethers-io/ethers.js/issues?state=all&per_page=100", cacheOnly)
let issues = await fetchGitHub(user, password, "https:/\/api.github.com/repos/ethers-io/ethers.js/issues?state=all&per_page=100", cacheOnly)
if (!cacheOnly) { console.log(`Found ${ issues.length } issues`); }
const result = [ ];
for (let i = 0; i < issues.length; i++) {

View File

@@ -11,6 +11,13 @@ Building
--------
```
/home/ricmoo/ethers.js> npm run build-docs
/home/ricmoo/ethers.js> npm run build-docs
```
License
-------
All documentation for ethers.js and Flatworm is released under the
[Creative Commons Attribution 4.0 International License](https://choosealicense.com/licenses/cc-by-4.0/)
license.

View File

@@ -130,14 +130,14 @@ _heading: Write Methods Analysis @<contract-write-check>
There are secveral options to analyze properties and results of a
write method without actually executing it.
_property: contract.estimate.METHOD_NAME(...args [ , overrides ]) => Promise<[[bignumber]]> @<contract-estimateGas>
_property: contract.estimateGas.METHOD_NAME(...args [ , overrides ]) => Promise<[[bignumber]]> @<contract-estimateGas>
Returns the estimate units of gas that would be required to
execute the //METHOD_NAME// with //args// and //overrides//.
_property: contract.populateTransaction.METHOD_NAME(...args [ , overrides ]) => Promise<[UnsignedTx](types-unsignedtransaction)> @<contract-populateTransaction>
Returns an [[types-unsignedtransaction]] which represents the transaction
that would need to be signed and submitted to the network to execute
//METHOD_NAME// with //args/ and //overrides//.
//METHOD_NAME// with //args// and //overrides//.
_property: contract.staticCall.METHOD_NAME(...args [ , overrides ]) => Promise<any> @<contract-staticCall>
Rather than executing the state-change of a transaction, it is possible

View File

@@ -2,7 +2,43 @@ _section: Example: ERC-20 Contract
_subsection: Connecting to a Contract
_code: token.txt
_code: A simple ERC-20 contract @lang<javascript>
// A Human-Readable ABI; any supported ABI format could be used
const abi = [
// Read-Only Functions
"function balanceOf(address owner) view returns (uint256)",
"function decimals() view returns (uint8)",
"function symbol() view returns (string)",
// Authenticated Functions
"function transfer(address to, uint amount) returns (boolean)",
// Events
"event Transfer(address indexed from, address indexed to, uint amount)"
];
// This can be an address or an ENS name
const address = "dai.tokens.ethers.eth";
// An example Provider
const provider = ethers.getDefaultProvider();
// An example Signer
const signer = ethers.Wallet.createRandom().connect(provider);
// Read-Only; By connecting to a Provider, allows:
// - Any constant function
// - Querying Filters
// - Populating Unsigned Transactions for non-constant methods
// - Estimating Gas for non-constant (as an anonymous sender)
// - Static Calling non-constant methods (as anonymous sender)
const erc20 = new ethers.Contract(address, abi, provider);
// Read-Write; By connecting to a Signer, allows:
// - Everything from Read-Only (except as Signer, not anonymous)
// - Sending transactions for non-constant functions
const erc20_rw = new ethers.Contract(address, abi, signer)
_heading: ERC20Contract @INHERIT<[[contract]]>
@@ -14,7 +50,7 @@ add the additional properties defined in //abi// to a **Contract**
connected to //address// using the //providerOrSigner//.
_subsection: Properties ^^//(inheritted from [[contract]])//^^
_subsection: Properties @NOTE<(inheritted from [[contract]])>
_property: erc20.address => string<[[address]]>
This is the address (or ENS name) the contract was constructed with.
@@ -40,7 +76,7 @@ _property: erc20.signer => [[signer]]
If a signer was provided to the constructor, this is that signer.
_subsection: Methods ^^//(inheritted from [[contract]])//^^
_subsection: Methods @NOTE<(inheritted from [[contract]])>
_property: erc20.attach(addressOrName) => [[contract]]
Returns a new instance of the **Contract** attached to a new
@@ -63,7 +99,7 @@ _property: erc20.deployed() => Promise<Contract>
_property: Contract.isIndexed(value) => boolean
_subsection: Events ^^//(inheritted from Contract)//^^ @<erc20-events>
_subsection: Events @NOTE<(inheritted from [[contract]])> @<erc20-events>
_property: erc20.queryFilter(event [ , fromBlockOrBlockHash [ , toBlock ]) => Promise<Array<Event>> @<erc20-queryfilter>
Return Events that match the //event//.
@@ -90,7 +126,7 @@ Unsubscribe all listeners for //event//. If no event is provided,
all events are unsubscribed.
_subsection: Meta-Class Methods ^^//(added at Runtime)//^^
_subsection: Meta-Class Methods @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**.
@@ -137,7 +173,7 @@ blockchain also means there are certain consistency modes that cannot be
known until an actual transaction is attempted.
_subsection: Meta-Class Filters ^^//(added at Runtime)//^^
_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**.

View File

@@ -1,35 +0,0 @@
// A Human-Readable ABI; any supported ABI format could be used
const abi = [
// Read-Only Functions
"function balanceOf(address owner) view returns (uint256)",
"function decimals() view returns (uint8)",
"function symbol() view returns (string)",
// Authenticated Functions
"function transfer(address to, uint amount) returns (boolean)",
// Events
"event Transfer(address indexed from, address indexed to, uint amount)"
];
// This can be an address or an ENS name
const address = "demotoken.ethers.eth";
// An example Provider (connceted to testnet)
const provider = ethers.getDefaultProvider("ropsten");
// An example Signer
const signer = ethers.Wallet.createRandom(provider);
// Read-Only; By connecting to a Provider, allows:
// - Any constant function
// - Querying Filters
// - Populating Unsigned Transactions for non-constant methods
// - Estimating Gas for non-constant (as an anonymous sender)
// - Static Calling non-constant methods (as anonymous sender)
const erc20 = new ethers.Contract(address, abi, provider);
// Read-Write; By connecting to a Signer, allows:
// - Everything from Read-Only (except as Signer, not anonymous)
// - Sending transactions for non-constant functions
const erc20_rw = new ethers.Contract(address, abi, signer)

View File

@@ -0,0 +1,65 @@
_section: Experimental
The **Experimental** package is used for features that are not ready
to be included in the base library. The API should not be considered
stable and does not follow [[link-semver]] versioning, so applications
requiring it should specify the //exact version// needed.
_subsection: BrainWallet @<experimental-brainwallet> @INHERIT<[[wallet]]>
Ethers removed support for BrainWallets in v4, since they are unsafe and
many can be easily guessed, allowing attackers to steal the funds. This
class is offered to ensure older systems which used brain wallets can
still recover their funds and assets.
_property: BrainWallet.generate(username, password [ , progressCallback ]) => [[experimental-brainwallet]]
Generates a brain wallet, with a slightly improved experience, in which
the generated wallet has a mnemonic.
_property: BrainWallet.generateLegacy(username, password [ , progressCallback ]) => [[experimental-brainwallet]]
Generate a brain wallet which is compatibile with the ethers v3 and earlier.
_subsection: EIP1193Bridge @<experimental-eip1193bridge> @INHERIT<[[link-npm-events]]>
The **EIP1193Bridge** allows a normal Ethers [[signer]] and [[provider]] to be
exposed in as a standard [EIP-1193 Provider](link-eip-1193), which may be useful
when interacting with other libraries.
_subsection: NonceManager @<experimental-noncemanager> @INHERIT<[[signer]]>
The **NonceManager** is designed to manage the nonce for a Signer,
automatically increasing it as it sends transactions.
Currently the NonceManager does not handle re-broadcast. If you attempt
to send a lot of transactions to the network on a node that does not
control that account, the transaction pool may drop your transactions.
In the future, it'd be nice if the **NonceManager** remembered transactions
and watched for them on the network, rebroadcasting transactions that
appear to have been dropped.
Another future feature will be some sort of failure mode. For example, often
a transaction is dependent on another transaction being mined first.
_property: new NonceManager(signer)
Create a new NonceManager.
_property: nonceManager.signer => [[signer]]
The signer whose nonce is being managed.
_property: nonceManager.provider => [[provider]]
The provider associated with the signer.
_property: nonceManager.setTransactionCount(count) => void
Set the current transaction count (nonce) for the signer.
This may be useful it interacting with the signer outside of using
this class.
_property: nonceManager.increaseTransactionCount( [ count = 1 ]) => void
Bump the current transaction count (nonce) by //count//.
This may be useful it interacting with the signer outside of using
this class.

View File

@@ -1,6 +1,7 @@
_section: Application Programming Interface @NAV<API>
Here...
An Application Programming Interface (API) is the formal
specification of the library.
_toc:
contract
@@ -8,3 +9,4 @@ _toc:
providers
utils
other
experimental

View File

@@ -56,9 +56,9 @@ _definition: **Supported Networks**
- Kovan (proof-of-authority testnet)
_subsection: CloudfrontProvider @INHERIT<[[provider-urljsonrpc]]>
_subsection: CloudflareProvider @INHERIT<[[provider-urljsonrpc]]>
The CloudfrontProvider is backed by the [Cloudflare Ethereum Gateway](link-cloudflare).
The CloudflareProvider is backed by the [Cloudflare Ethereum Gateway](link-cloudflare).
_definition: **Supported Networks**

View File

@@ -1,29 +0,0 @@
// <hide>
const { ethers } = require("./packages/ethers");
const provider = ethers.getDefaultProvider()
function _inspect(result) {
if (ethers.BigNumber.isBigNumber(result)) {
return `{ BigNumber: ${ JSON.stringify(result.toString()) } }`;
}
return JSON.stringify(result);
}
// </hide>
// Get the balance for an account...
provider.getBalance("ricmoo.firefly.eth");
//!
// Get the code for a contract...
provider.getCode("registrar.firefly.eth");
//!
// Get the storage value at position 0...
provider.getStorageAt("registrar.firefly.eth", 0)
//!
// Get transaction count of an account...
provider.getTransactionCount("ricmoo.firefly.eth");
//!

View File

@@ -1,15 +0,0 @@
// <hide>
const { ethers } = require("./packages/ethers");
const provider = ethers.getDefaultProvider()
// </hide>
// Reverse lookup of an ENS by address...
provider.lookupAddress("0x6fC21092DA55B392b045eD78F4732bff3C580e2c");
//!
// Lookup an address of an ENS name...
provider.resolveName("ricmoo.firefly.eth");
//!

View File

@@ -7,8 +7,8 @@ and [Parity](link-parity)) as well as many third-party web
services (e.g. [INFURA](link-infura))
_property: new ethers.providers.JsonRpcProvider([ url [ , aNetworkish ] ])
Connect to a JSON-RPC API located at //url// using the /aNetworkish// network.
If //url// is not specified, the default (i.e. ``http://localhost:8545``) is used
Connect to a JSON-RPC API located at //url// using the //aNetworkish// network.
If //url// is not specified, the default (i.e. ``http:/\/localhost:8545``) is used
and if no network is specified, it will be determined automatically by
querying the node.

View File

@@ -5,24 +5,44 @@ Explain what a provider is...
_subsection: Accounts Methods
_property: provider.getBalance(address [ , blockTag = "latest" ]) => Promise<[[bignumber]]> @<provider-getbalance> @SRC<providers/base-provider>
_property: provider.getBalance(address [ , blockTag = latest ]) => Promise<[[bignumber]]> @<provider-getbalance> @SRC<providers/base-provider>
Returns the balance of //address// as of the //blockTag// block height.
_property: provider.getCode(address [ , blockTag = "latest" ]) => Promise<string<[[datahexstring]]>> @<providers-getcode> @SRC<providers/base-provider>
_property: provider.getCode(address [ , blockTag = latest ]) => Promise<string<[[datahexstring]]>> @<providers-getcode> @SRC<providers/base-provider>
Returns the contract code of //address// as of the //blockTag// block height. If there is
no contract currently deployed, the result is ``0x``.
_property: provider.getStorageAt(addr, pos [ , blockTag = "latest" ]) => Promise<string<[[datahexstring]]>> @<providers-getstorageat> @SRC<providers/base-provider>
_property: provider.getStorageAt(addr, pos [ , blockTag = latest ]) => Promise<string<[[datahexstring]]>> @<providers-getstorageat> @SRC<providers/base-provider>
Returns the ``Bytes32`` value of the position //pos// at address //addr//, as of the //blockTag//.
_property: provider.getTransactionCount(address [ , blockTag = "latest" ]) => Promise<number> @<providers-gettransactioncount> @SRC<providers/base-provider>
_property: provider.getTransactionCount(address [ , blockTag = latest ]) => Promise<number> @<providers-gettransactioncount> @SRC<providers/base-provider>
Returns the number of transactions //address// has ever **sent**, as of //blockTag//.
This value is required to be the nonce for the next transaction from //address//
sent to the network.
_heading: Examples
_code: example-account.js
_code: @lang<javascript>
// <hide>
const provider = ethers.getDefaultProvider()
// </hide>
// Get the balance for an account...
provider.getBalance("ricmoo.firefly.eth");
//!
// Get the code for a contract...
provider.getCode("registrar.firefly.eth");
//!
// Get the storage value at position 0...
provider.getStorageAt("registrar.firefly.eth", 0)
//!
// Get transaction count of an account...
provider.getTransactionCount("ricmoo.firefly.eth");
//!
_subsection: Blocks Methods
@@ -52,7 +72,20 @@ not have an address configured, ``null`` is returned.
_heading: Examples
_code: example-ens.js
_code: @lang<javascript>
// <hide>
const provider = ethers.getDefaultProvider()
// </hide>
// Reverse lookup of an ENS by address...
provider.lookupAddress("0x6fC21092DA55B392b045eD78F4732bff3C580e2c");
//!
// Lookup an address of an ENS name...
provider.resolveName("ricmoo.firefly.eth");
//!
_subsection: Logs Methods
@@ -78,7 +111,7 @@ Returns a //best guess// of the [[gas-price]] to use in a transaction.
_subsection: Transactions Methods
_property: provider.call(transaction [ , blockTag = "latest" ]) => Promise<string<[[hexstring]]>> @<providers-call> @SRC<providers/base-provider>
_property: provider.call(transaction [ , blockTag = latest ]) => Promise<string<[[datahexstring]]>> @<providers-call> @SRC<providers/base-provider>
Returns the result of executing the //transaction//, using //call//. A call
does not require any ether, but cannot change any state. This is useful
for calling gettings on Contracts.
@@ -96,7 +129,7 @@ Submits //transaction// to the network to be mined. The //transaction// **must**
and be valid (i.e. the nonce is correct and the account has sufficient balance to pay
for the transaction).
_property: provider.waitForTransaction(transactionHash) => Promise<[[provider-receipt]]> @<providers-waitfortransaction> @SRC<providers/base-provider>
_property: provider.waitForTransaction(hash [ , confirms = 1 [ , timeout ] ]) => Promise<[TxReceipt](provider-receipt)> @<providers-waitfortransaction> @SRC<providers/base-provider>
Returns a Promise which will not resolve until //transactionHash// is mined.

View File

@@ -236,11 +236,11 @@ _property: receipt.from => string<[[address]]>
The address this transaction is from.
_property: receipt.contractAddress => string<[[address]]>
If this transaction has a ``null` to address, it is an **init transaction**
If this transaction has a ``null`` to address, it is an **init transaction**
used to deploy a contract, in which case this is the address created by that
contract.
To compute a contract address, the [getContractAddress](utils-getcontractaddress)
To compute a contract address, the [getContractAddress](utils-getContractAddress)
utility function can also be used with a [[provider-transactionresponse]]
object, which requires the transaction nonce and the address of the sender.

View File

@@ -146,6 +146,13 @@ Create an instance from an encrypted JSON wallet. If //progress//
is provided it will be called during decryption with a value between 0 and
1 indicating the progress towards completion.
_property: ethers.Wallet.fromEncryptedJsonSync(json, password) => [[wallet]] @<wallet-fromencryptedjsonsync> @SRC<wallet>
Create an instance from an encrypted JSON wallet.
This operation will operate synchronously which will lock up the user
interface, possibly for a non-trivial duration. Most applications should
use the asynchronous ``fromEncryptedJson`` instead.
_property: ethers.Wallet.fromMnemonic(mnemonic [ , path, [ wordlist ] ]) => [[wallet]]
Create an instance from a mnemonic phrase.

View File

@@ -1,5 +1,19 @@
_section: Application Binary Interface @NAV<ABI>
An **Application Binary Interface** (ABI) is a collection of
[Fragments](abi-fragment) which specify how to interact with
various components of a Contract.
An [[abi-interface]] helps organize Fragments by type as well
as provides the functionality required to encode, decode and
work with each component.
Most developers will not require this low-level access to encoding
and decoding the binary data on the network and will most likely
use a [[contract]] which provides a more convenient interface. Some
framework, tool developers or developers using advanced techniques
may find these classes and utilities useful.
_toc:
interface
fragments

View File

@@ -187,10 +187,10 @@ _subsection: Specifying Fragments @<abi-fragmentid>
When specifying a fragment to any of the functions in an **Interface**,
any of the following may be used:
- The name of the event or function, if it is unique and non-ambiguous
- The **name** of the event or function, if it is unique and non-ambiguous
within the ABI (e.g. ``transfer``)
- The signature of the event or function. The signature is normalized,
- The **signature** of the event or function. The signature is normalized,
so, for example, ``uint`` and ``uint256`` are equivalent (e.g. ``transfer(address, uint)``)
- The sighash or topichash of the function. The sighash is often referred
- The **sighash** or **topichash** of the function. The sighash is often referred
to the function selector in Solidity (e.g. ``0xa9059cbb``)
- A [[abi-fragment]]
- A [[abi-fragment]]

View File

@@ -39,7 +39,7 @@ accepts an address can receive an ICAP address, and it will be converted interna
To convert an address into the ICAP format, see [getIcapAddress](utils-getIcapAddress).
_subsection: Functions
_subsection: Converting and Verifying @<urils--address-basic>
_property: ethers.utils.getAddress(address) => string<[[address]]> @<utils-getAddress> @SRC<address>
Returns //address// as a Checksum Address.
@@ -49,18 +49,35 @@ the checksum is invalid, an InvalidArgument Error is throw.
The value of //address// may be any supported address format.
_property: ethers.utils.isAddress(address) => boolean @<utils-isAddress> @SRC<address>
Returns true if //address// is valid (in any supported format).
_property: ethers.utils.getIcapAddress(address) => string<[IcapAddress](address-icap)> @<utils-getIcapAddress> @SRC<address>
Returns //address// as an [ICAP address](link-icap).
Supports the same restrictions as [utils.getAddress](utils-getAddress).
_property: ethers.utils.getContractAddress(transaction) => string<[[address]]> @<utils-getcontractaddress> @SRC<address>
_property: ethers.utils.isAddress(address) => boolean @<utils-isAddress> @SRC<address>
Returns true if //address// is valid (in any supported format).
_subsection: Derivation @<utils--address-computation>
_property: ethers.utils.computeAddress(publicOrPrivateKey) => string<[[address]]> @<utils-computeAddress> @SRC<transactions>
Returns the address for //publicOrPrivateKey//. A public key may be
compressed or uncompressed, and a private key will be converted
automatically to a public key for the derivation.
_property: ethers.utils.recoverAddress(digest, signature) => string<[[address]]> @<utils-recoverAddress> @SRC<transactions>
Use [[link-wiki-ecrecover]] to determine the address that signed //digest// to
which generated //signature//.
_subsection: Contracts Addresses @<utils--contract-addresses>
_property: ethers.utils.getContractAddress(transaction) => string<[[address]]> @<utils-getContractAddress> @SRC<address>
Returns the contract address that would result if //transaction// was
used to deploy a contract.
_property: ethers.utils.getCreate2Address(from, salt, initCodeHash) => string<[[address]]> @<utils-getCreate2Address> @SRC<address>
Returns the contract address that would result from the given
[CREATE2](link-eip-1014) call.

View File

@@ -1,50 +0,0 @@
// <hide>
const { BigNumber } = require("./packages/ethers");
const { constants } = require("./packages/ethers");
function _inspect(result) {
if (BigNumber.isBigNumber(result)) {
return `{ BigNumber: ${ JSON.stringify(result.toString()) } }`;
}
return result;
}
// </hide>
// From a decimal string...
BigNumber.from("42")
//!
// From a hexstring...
BigNumber.from("0x2a")
//!
// From a negative hexstring...
BigNumber.from("-0x2a")
//!
// From an Array (or Uint8Array)...
BigNumber.from([ 42 ])
//!
// From an existing BigNumber...
let one1 = constants.One;
let one2 = BigNumber.from(one1)
one2
//!
// ...which returns the same instance
one1 === one2
//!
// From a (safe) number...
BigNumber.from(42)
//!
// From a ES2015 BigInt... (only on platforms with BigInt support)
BigNumber.from(42n)
//!
// Numbers outside the safe range fail:
BigNumber.from(Number.MAX_SAFE_INTEGER);
//! error

View File

@@ -1,16 +0,0 @@
// <hide>
const { BigNumber } = require("./packages/ethers");
function _inspect(result) {
if (BigNumber.isBigNumber(result)) {
return `{ BigNumber: ${ JSON.stringify(result.toString()) } }`;
}
return result;
}
// </hide>
let a = BigNumber.from(42);
let b = BigNumber.from("91");
a.mul(b);
//!

View File

@@ -1,2 +0,0 @@
(Number.MAX_SAFE_INTEGER + 2 - 2) == (Number.MAX_SAFE_INTEGER)
//!

View File

@@ -1,18 +0,0 @@
/////
// CommonJS:
// From the Umbrella ethers package...
const { BigNumber } = require("ethers");
// From the bignumber pacakge...
const { BigNumber } = require("@ethersproject/bignumber");
/////
// ES6 and TypeScript:
// From the Umbrella ethers package...
import { BigNumber } from "ethers";
// From the bignumber pacakge...
import { BigNumber } from "@ethersproject/bignumber";

View File

@@ -13,7 +13,23 @@ and parameters which accept values will generally accept them.
_heading: Importing
_code: bignumber-import.source
_code: CommonJS @lang<script>
// From the Umbrella ethers package...
const { BigNumber } = require("ethers");
// From the bignumber pacakge...
const { BigNumber } = require("@ethersproject/bignumber");
_code: ES6 and TypeScript CommonJS @lang<script>
// From the Umbrella ethers package...
import { BigNumber } from "ethers";
// From the bignumber pacakge...
import { BigNumber } from "@ethersproject/bignumber";
_subsection: Types
@@ -50,7 +66,46 @@ Returns an instance of a **BigNumber** for //aBigNumberish//.
_heading: Examples: @<>
_code: bignumber-create.js
_code: @lang<javascript>
// From a decimal string...
BigNumber.from("42")
//!
// From a hexstring...
BigNumber.from("0x2a")
//!
// From a negative hexstring...
BigNumber.from("-0x2a")
//!
// From an Array (or Uint8Array)...
BigNumber.from([ 42 ])
//!
// From an existing BigNumber...
let one1 = constants.One;
let one2 = BigNumber.from(one1)
one2
//!
// ...which returns the same instance
one1 === one2
//!
// From a (safe) number...
BigNumber.from(42)
//!
// From a ES2015 BigInt... (only on platforms with BigInt support)
BigNumber.from(42n)
//!
// Numbers outside the safe range fail:
BigNumber.from(Number.MAX_SAFE_INTEGER);
//! error
_subsection: Methods
@@ -65,16 +120,16 @@ _property: bignumber.add(otherValue) => [[bignumber]] @SRC<bignumber>
Returns a BigNumber with the value of //bignumber// **+** //otherValue//.
_property: bignumber.sub(otherValue) => [[bignumber]] @SRC<bignumber>
Returns a BigNumber with the value of //bignumber// **&ndash;** //otherValue//.
Returns a BigNumber with the value of //bignumber// **-** //otherValue//.
_property: bignumber.mul(otherValue) => [[bignumber]] @SRC<bignumber>
Returns a BigNumber with the value of //bignumber// **&times;** //otherValue//.
_property: bignumber.div(divisor) => [[bignumber]] @SRC<bignumber>
Returns a BigNumber with the value of //bignumber// **&#247;** //divisor//.
Returns a BigNumber with the value of //bignumber// **&div;** //divisor//.
_property: bignumber.mod(divisor) => [[bignumber]] @SRC<bignumber>
Returns a BigNumber with the value of the **remainder** of //bignumber// &#247; //divisor//.
Returns a BigNumber with the value of the **remainder** of //bignumber// &div; //divisor//.
_property: bignumber.pow(exponent) => [[bignumber]] @SRC<bignumber>
Returns a BigNumber with the value of //bignumber// to the power of //exponent//.
@@ -82,7 +137,7 @@ Returns a BigNumber with the value of //bignumber// to the power of //exponent//
_property: bignumber.abs() => [[bignumber]] @SRC<bignumber>
Returns a BigNumber with the absolute value of //bignumber//.
_property: bignumber.maskn(bitcount) => [[bignumber]] @SRC<bignumber>
_property: bignumber.mask(bitcount) => [[bignumber]] @SRC<bignumber>
Returns a BigNumber with the value of //bignumber// with bits beyond
the //bitcount// least significant bits set to zero.
@@ -146,7 +201,13 @@ Returns true if and only if the //object// is a BigNumber object.
_heading: Examples
_code: bignumber-examples.js
_code: @lang<javascript>
let a = BigNumber.from(42);
let b = BigNumber.from("91");
a.mul(b);
//!
_subsection: Notes
@@ -171,13 +232,18 @@ experience rounding errors.
To demonstrate how this may be an issue in your code, consider:
_code: bignumber-ieee754.js
_code: @lang<javascript>
(Number.MAX_SAFE_INTEGER + 2 - 2) == (Number.MAX_SAFE_INTEGER)
//!
_null:
To remedy this, all numbers (which can be large) are stored
and manipulated as [Big Numbers](bignumber).
The functions [parseEther( etherString )](http://linkto) and
[formatEther( wei )](http://linkto) can be used to convert
The functions [parseEther( etherString )](utils-parseether) and
[formatEther( wei )](utils-formatether) can be used to convert
between string representations, which are displayed to or entered
by the user and Big Number representations which can have
mathematical operations handled safely.
@@ -222,7 +288,7 @@ over other libraries which include separate Big Number libraries for
various purposes.
_heading: Why not allow us to set a global Big Number library?
_heading: Allow us to set a global Big Number library?
Another comment that comes up frequently is tha desire to specify a
global user-defined Big Number library, which all functions would

View File

@@ -1,37 +0,0 @@
// <hide>
const { ethers } = require("./packages/ethers");
const { arrayify, hexlify, hexValue } = ethers.utils;
function _inspect(result) {
if (result && typeof(result.length) === "number" && typeof(result) !== "string") {
return "[ " + Array.prototype.map.call(result, (i) => _inspect(i)).join(", ") + " ]";
}
return result;
}
// </hide>
// Convert a hexstring to a Uint8Array
arrayify("0x1234")
//!
// Convert an Array to a hexstring
hexlify([1, 2, 3, 4])
//!
// Convert an Object to a hexstring
hexlify({ length: 2, "0": 1, "1": 2 })
//!
// Convert an Array to a hexstring
hexlify([ 1 ])
//!
// Convert a number to a stripped hex value
hexValue(1)
//!
// Convert an Array to a stripped hex value
hexValue([ 1, 2 ])
//!

View File

@@ -79,7 +79,31 @@ zeros.
_heading: Examples
_code: bytes-conversion.js
_code: @lang<javascript>
// Convert a hexstring to a Uint8Array
arrayify("0x1234")
//!
// Convert an Array to a hexstring
hexlify([1, 2, 3, 4])
//!
// Convert an Object to a hexstring
hexlify({ length: 2, "0": 1, "1": 2 })
//!
// Convert an Array to a hexstring
hexlify([ 1 ])
//!
// Convert a number to a stripped hex value
hexValue(1)
//!
// Convert an Array to a stripped hex value
hexValue([ 1, 2 ])
//!
_subsection: Array Manipulation
@@ -139,3 +163,16 @@ Return a new Uint8Array of //length// random bytes.
_property: ethers.utils.shuffled(array) => Array<any> @<utils.shuffled> @SRC<random>
Return a copy of //array// shuffled using [[link-wiki-shuffle]].
_code: Examples @lang<javascript>
utils.randomBytes(8)
//!
const foo = [ 1, 2, 3, 4, 5, 6, 7 ];
utils.shuffled(foo);
//!
// The original array is unscathed...
foo
//!

View File

@@ -1,3 +0,0 @@
//const { constants } = require("ethers");
// const { constants } = require("@ethersproject/constants");

View File

@@ -4,7 +4,10 @@ The **ethers.contants** Object contains commonly used values.
_heading: Importing
_code: constants-import.js
_code: @lang<script>
const { constants } = require("ethers");
const { constants } = require("@ethersproject/constants");
_subsection: Bytes

View File

@@ -21,23 +21,29 @@ _subsection: Units
_heading: Decimal Count
The //unit// specified may be an integer, which indicates how
many decimal place the unit has. For example, 1 ether has 18 decimal
places for wei, and if this library were used with Bitcoin, 1 BTC
has 8 decimal places for satoshis.
A **Unit** can be specified as an number, which indicates the
number of decimal places that should be used.
**Examples:**
- 1 ether in wei, has **18** decimal places (i.e. 1 ether represents 10^^18^^ wei)
- 1 bitcoin in Satoshi, has **8** decimal places (i.e. 1 bitcoin represents 10^^8^^ satoshi)
_heading: Named Units
In addition to specifying //unit// as a number of decimals, there
are several common units, which can be passed in as a string:
There are also several common **Named Units**, in which case their name (as
a string) may be used.
- **wei** --- 0
- **kwei** --- 3
- **mwei** --- 6
- **gwei** --- 9
- **szabo** --- 12
- **finney** --- 15
- **ether** --- 18
_table: @STYLE<compact>
| **Name** | **Decimals** |
| //wei// | 0 |
| //kwei// | 3 |
| //mwei// | 6 |
| //gwei// | 9 |
| //szabo// | 12 |
| //finney// | 15 |
| //ether// | 18 |
_subsection: Functions

View File

@@ -93,10 +93,10 @@ larger than 256 bits and the number of decimals must be no larger than 80.
For example:
- **fixed128x18** is signed, 128 bits wide and has 18 decimals; this is useful for most purposes
- **fixed32x0** is signed, 32 bits wide and has 0 decimals; this would be the same as a ``int32_t` in C
- **ufixed32x0** is unsigned, 32 bits wide and has 0 decimals; this would be the same as a ``uint32_t` in C
- **fixed** is shorthand for ``fixed128x18`
- **ufixed** is shorthand for ``ufixed128x18`
- **fixed32x0** is signed, 32 bits wide and has 0 decimals; this would be the same as a ``int32_t`` in C
- **ufixed32x0** is unsigned, 32 bits wide and has 0 decimals; this would be the same as a ``uint32_t`` in C
- **fixed** is shorthand for ``fixed128x18``
- **ufixed** is shorthand for ``ufixed128x18``
_heading: Creating Instances

View File

@@ -1,6 +1,6 @@
_section: Property Utilities
_property: ethers.utils.checkPropertoes() => void
_property: ethers.utils.checkProperties() => void
_property: ethers.utils.deepCopy(anObject) => any
_property: ethers.utils.defineReadOnly(anObject, name, value) => void

View File

@@ -14,7 +14,7 @@ _property: signingKey.compressedPublicKey => string<[[datahexstring]]<33>>
The compressed public key for this Signing Key. It will always be
33 bytes (66 nibbles) and begine with either ``0x02`` or ``0x03``.
_property: signingKey.signDisgest(digest) => [[signature]]
_property: signingKey.signDigest(digest) => [[signature]]
Sign the //digest// and return the signature.
_property: signingKey.computeSharedSecret(otherKey) => string<[[datahexstring]]<32>>
@@ -39,7 +39,7 @@ will then be used to compute the address; this allows systems which use
the v to encode additional data (such as [EIP-155](link-eip-155))
to be used since the v parameter is still completely non-ambiguous.
_property: ethers.utils.recocverPublicKey(digest, signature) => string<[[datahexstring]]<65>> @<utils-recoverpublickey>
_property: ethers.utils.recoverPublicKey(digest, signature) => string<[[datahexstring]]<65>> @<utils-recoverpublickey>
_property: ethers.utils.computePublicKey(key [, compressed = false ]) => string<[[datahexstring]]> @<utils-computepublickey>
Computes the public key of //key//, optionally compressing it. The //key//

View File

@@ -1,11 +0,0 @@
/home/ethers> ethers-asm SimpleStore.asm
0x602a6000556044601160003960446000f334601e5760003560e01c80632096525514602457806355241077146030575b60006000fd5b60005460005260206000f35b6024361415601e5760043560005560006000f3
# Piping in ASM source code
/home/ethers> cat SimpleStore.asm | ethers-asm
# Same as above
# Setting a define which the ASM file checks and adds a checksum
/home/ethers> ethers-asm --define checksum SimpleStore.asm
0x602a6000556065601160003960656000f334601e5760003560e01c80632096525514602457806355241077146030575b60006000fd5b60005460005260206000f35b6024361415601e5760043560005560006000f37f10358310d664c9aeb4bf4ce7a10a6a03176bd23194c8ccbd3160a6dac90774d6

View File

@@ -1,57 +0,0 @@
/home/ethers> ethers-asm --disassemble SimpleStore.bin
0000 : 0x2a ; #1
0002 : 0x00 ; #1
0004 : SSTORE
0005 : 0x44 ; #1
0007 : 0x11 ; #1
0009 : 0x00 ; #1
000b : CODECOPY
000c : 0x44 ; #1
000e : 0x00 ; #1
0010 : RETURN
0011 : CALLVALUE
0012 : 0x1e ; #1
0014 : JUMPI
0015 : 0x00 ; #1
0017 : CALLDATALOAD
0018 : 0xe0 ; #1
001a : SHR
001b : DUP1
001c : 0x20965255 ; #4
0021 : EQ
0022 : 0x24 ; #1
0024 : JUMPI
0025 : DUP1
0026 : 0x55241077 ; #4
002b : EQ
002c : 0x30 ; #1
002e : JUMPI
002f*: JUMPDEST
0030 : 0x00 ; #1
0032 : 0x00 ; #1
0034 : REVERT
0035*: JUMPDEST
0036 : 0x00 ; #1
0038 : SLOAD
0039 : 0x00 ; #1
003b : MSTORE
003c : 0x20 ; #1
003e : 0x00 ; #1
0040 : RETURN
0041*: JUMPDEST
0042 : 0x24 ; #1
0044 : CALLDATASIZE
0045 : EQ
0046 : ISZERO
0047 : 0x1e ; #1
0049 : JUMPI
004a : 0x04 ; #1
004c : CALLDATALOAD
004d : 0x00 ; #1
004f : SSTORE
0050 : 0x00 ; #1
0052 : 0x00 ; #1
0054 : RETURN
/home/ethers> cat SimpleStore.bin | ethers-asm --disassemble
# Same as above

View File

@@ -1,14 +0,0 @@
Usage:
ethers-asm [ FILENAME ] [ OPTIONS ]
OPTIONS
--define KEY=VALUE provide assembler defines
--disassemble Disassemble input bytecode
--ignore-warnings Ignore warnings
--pic generate position independent code
--target LABEL output LABEL bytecode (default: _)
OTHER OPTIONS
--debug Show stack traces for errors
--help Show this usage and exit
--version Show this version and exit

View File

@@ -1,48 +0,0 @@
; SimpleStore (uint)
; Set the inital value of 42
sstore(0, 42)
; Init code to deploy myContract
codecopy(0, $myContract, #myContract)
return(0, #myContract)
@myContract {
; Non-payable
jumpi($error, callvalue)
; Get the Sighash
shr({{= 256 - 32 }}, calldataload(0))
; getValue()
dup1
{{= sighash("getValue()") }}
jumpi($getValue, eq)
; setValue(uint)
dup1
{{= sighash("setValue(uint)") }}
jumpi($setValue, eq)
; No matching signature
@error:
revert(0, 0)
@getValue:
mstore(0, sload(0))
return (0, 32)
@setValue:
; Make sure we have exactly a uint
jumpi($error, iszero(eq(calldatasize, 36)))
; Store the value
sstore(0, calldataload(4))
return (0, 0)
; There is no *need* for the PUSH32, it just makes
; decompiled code look nicer
@checksum[
{{= (defines.checksum ? concat([ Opcode.from("PUSH32"), id(myContract.source) ]): "0x") }}
]
}

View File

@@ -1,3 +0,0 @@
0x602a6000556044601160003960446000f334601e5760003560e01c8063209652
0x5514602457806355241077146030575b60006000fd5b60005460005260206000
0xf35b6024361415601e5760043560005560006000f3

View File

@@ -7,18 +7,88 @@ and disassemle EVM bytecode into human-readable mnemonics.
_subsection: Help
_code: asm-help.txt
_code: @lang<text>
Usage:
ethers-asm [ FILENAME ] [ OPTIONS ]
OPTIONS
--define KEY=VALUE provide assembler defines
--disassemble Disassemble input bytecode
--ignore-warnings Ignore warnings
--pic generate position independent code
--target LABEL output LABEL bytecode (default: _)
OTHER OPTIONS
--debug Show stack traces for errors
--help Show this usage and exit
--version Show this version and exit
_subsection: Example Input Files
_definition: **SimpleStore.asm**
_code: asm-simplestore-asm.txt
_code: @lang<asm>
; SimpleStore (uint)
; Set the inital value of 42
sstore(0, 42)
; Init code to deploy myContract
codecopy(0, $myContract, #myContract)
return(0, #myContract)
@myContract {
; Non-payable
jumpi($error, callvalue)
; Get the Sighash
shr({{= 256 - 32 }}, calldataload(0))
; getValue()
dup1
{{= sighash("getValue()") }}
jumpi($getValue, eq)
; setValue(uint)
dup1
{{= sighash("setValue(uint)") }}
jumpi($setValue, eq)
; No matching signature
@error:
revert(0, 0)
@getValue:
mstore(0, sload(0))
return (0, 32)
@setValue:
; Make sure we have exactly a uint
jumpi($error, iszero(eq(calldatasize, 36)))
; Store the value
sstore(0, calldataload(4))
return (0, 0)
; There is no *need* for the PUSH32, it just makes
; decompiled code look nicer
@checksum[
{{= (defines.checksum ? concat([ Opcode.from("PUSH32"), id(myContract.source) ]): "0x") }}
]
}
_definition: **SimpleStore.bin**
_code: asm-simplestore-bin.txt
_code: @lang<text>
0x602a6000556044601160003960446000f334601e5760003560e01c8063209652
0x5514602457806355241077146030575b60006000fd5b60005460005260206000
0xf35b6024361415601e5760043560005560006000f3
_note: Note: Bytecode File Syntax
A bin file may be made up of multiple blocks of bytecode, each may
@@ -38,7 +108,19 @@ until the bytecode stablizes. This allows for more compact jump
destinations and for code to be include more advanced meta-programming
techniques.
_code: asm-examples-assemble.txt
_code: @lang<shell>
/home/ethers> ethers-asm SimpleStore.asm
0x602a6000556044601160003960446000f334601e5760003560e01c80632096525514602457806355241077146030575b60006000fd5b60005460005260206000f35b6024361415601e5760043560005560006000f3
# Piping in ASM source code
/home/ethers> cat SimpleStore.asm | ethers-asm
# Same as above
# Setting a define which the ASM file checks and adds a checksum
/home/ethers> ethers-asm --define checksum SimpleStore.asm
0x602a6000556065601160003960656000f334601e5760003560e01c80632096525514602457806355241077146030575b60006000fd5b60005460005260206000f35b6024361415601e5760043560005560006000f37f10358310d664c9aeb4bf4ce7a10a6a03176bd23194c8ccbd3160a6dac90774d6
_heading: Options
@@ -77,5 +159,62 @@ A disassembled program shows offsets and mnemonics for the given
bytecode. This format may change in the future to be more
human-readable.
_code: asm-examples-disassemble.txt
_code: @lang<shell>
/home/ethers> ethers-asm --disassemble SimpleStore.bin
0000 : 0x2a ; #1
0002 : 0x00 ; #1
0004 : SSTORE
0005 : 0x44 ; #1
0007 : 0x11 ; #1
0009 : 0x00 ; #1
000b : CODECOPY
000c : 0x44 ; #1
000e : 0x00 ; #1
0010 : RETURN
0011 : CALLVALUE
0012 : 0x1e ; #1
0014 : JUMPI
0015 : 0x00 ; #1
0017 : CALLDATALOAD
0018 : 0xe0 ; #1
001a : SHR
001b : DUP1
001c : 0x20965255 ; #4
0021 : EQ
0022 : 0x24 ; #1
0024 : JUMPI
0025 : DUP1
0026 : 0x55241077 ; #4
002b : EQ
002c : 0x30 ; #1
002e : JUMPI
002f*: JUMPDEST
0030 : 0x00 ; #1
0032 : 0x00 ; #1
0034 : REVERT
0035*: JUMPDEST
0036 : 0x00 ; #1
0038 : SLOAD
0039 : 0x00 ; #1
003b : MSTORE
003c : 0x20 ; #1
003e : 0x00 ; #1
0040 : RETURN
0041*: JUMPDEST
0042 : 0x24 ; #1
0044 : CALLDATASIZE
0045 : EQ
0046 : ISZERO
0047 : 0x1e ; #1
0049 : JUMPI
004a : 0x04 ; #1
004c : CALLDATALOAD
004d : 0x00 ; #1
004f : SSTORE
0050 : 0x00 ; #1
0052 : 0x00 ; #1
0054 : RETURN
/home/ethers> cat SimpleStore.bin | ethers-asm --disassemble
# Same as above

View File

@@ -1,69 +0,0 @@
Usage:
ethers-ens COMMAND [ ARGS ] [ OPTIONS ]
COMMANDS
lookup [ NAME | ADDRESS [ ... ] ]
Lookup a name or address
commit NAME Submit a pre-commitment
[ --duration DAYS ] Register duration (default: 365 days)
[ --salt SALT ] SALT to blind the commit with
[ --secret SECRET ] Use id(SECRET) as the salt
[ --owner OWNER ] The target owner (default: current account)
reveal NAME Reveal a previous pre-commitment
[ --duration DAYS ] Register duration (default: 365 days)
[ --salt SALT ] SALT to blind the commit with
[ --secret SECRET ] Use id(SECRET) as the salt
[ --owner OWNER ] The target owner (default: current account)
set-controller NAME Set the controller (default: current account)
[ --address ADDRESS ] Specify another address
set-subnode NAME Set a subnode owner (default: current account)
[ --address ADDRESS ] Specify another address
set-resolver NAME Set the resolver (default: resolver.eth)
[ --address ADDRESS ] Specify another address
set-addr NAME Set the addr record (default: current account)
[ --address ADDRESS ] Specify another address
set-text NAME KEY VALUE Set a text record
set-email NAME EMAIL Set the email text record
set-website NAME URL Set the website text record
set-content NAME HASH Set the IPFS Content Hash
migrate-registrar NAME Migrate from the Legacy to the Permanent Registrar
transfer NAME NEW_OWNER Transfer registrant ownership
reclaim NAME Reset the controller by the registrant
[ --address ADDRESS ] Specify another address
ACCOUNT OPTIONS
--account FILENAME Load from a file (JSON, RAW or mnemonic)
--account RAW_KEY Use a private key (insecure *)
--account 'MNEMONIC' Use a mnemonic (insecure *)
--account - Use secure entry for a raw key or mnemonic
--account-void ADDRESS Use an address as a void signer
--account-void ENS_NAME Add the resolved address as a void signer
--account-rpc ADDRESS Add the address from a JSON-RPC provider
--account-rpc INDEX Add the index from a JSON-RPC provider
--mnemonic-password Prompt for a password for mnemonics
--xxx-mnemonic-password Prompt for a (experimental) hard password
PROVIDER OPTIONS (default: all + homestead)
--alchemy Include Alchemy
--etherscan Include Etherscan
--infura Include INFURA
--nodesmith Include nodesmith
--rpc URL Include a custom JSON-RPC
--offline Dump signed transactions (no send)
--network NETWORK Network to connect to (default: homestead)
TRANSACTION OPTIONS (default: query network)
--gasPrice GWEI Default gas price for transactions(in wei)
--gasLimit GAS Default gas limit for transactions
--nonce NONCE Initial nonce for the first transaction
--yes Always accept Siging and Sending
OTHER OPTIONS
--wait Wait until transactions are mined
--debug Show stack traces for errors
--help Show this usage and exit
--version Show this version and exit
(*) By including mnemonics or private keys on the command line they are
possibly readable by other users on your system and may get stored in
your bash history file. This is NOT recommended.

View File

@@ -2,7 +2,78 @@ _section: Ethereum Naming Service @NAV<ENS>
_subsection: Help
_code: ens-help.txt
_code: @lang<text>
Usage:
ethers-ens COMMAND [ ARGS ] [ OPTIONS ]
COMMANDS
lookup [ NAME | ADDRESS [ ... ] ]
Lookup a name or address
commit NAME Submit a pre-commitment
[ --duration DAYS ] Register duration (default: 365 days)
[ --salt SALT ] SALT to blind the commit with
[ --secret SECRET ] Use id(SECRET) as the salt
[ --owner OWNER ] The target owner (default: current account)
reveal NAME Reveal a previous pre-commitment
[ --duration DAYS ] Register duration (default: 365 days)
[ --salt SALT ] SALT to blind the commit with
[ --secret SECRET ] Use id(SECRET) as the salt
[ --owner OWNER ] The target owner (default: current account)
set-controller NAME Set the controller (default: current account)
[ --address ADDRESS ] Specify another address
set-subnode NAME Set a subnode owner (default: current account)
[ --address ADDRESS ] Specify another address
set-resolver NAME Set the resolver (default: resolver.eth)
[ --address ADDRESS ] Specify another address
set-addr NAME Set the addr record (default: current account)
[ --address ADDRESS ] Specify another address
set-text NAME KEY VALUE Set a text record
set-email NAME EMAIL Set the email text record
set-website NAME URL Set the website text record
set-content NAME HASH Set the IPFS Content Hash
migrate-registrar NAME Migrate from the Legacy to the Permanent Registrar
transfer NAME NEW_OWNER Transfer registrant ownership
reclaim NAME Reset the controller by the registrant
[ --address ADDRESS ] Specify another address
ACCOUNT OPTIONS
--account FILENAME Load from a file (JSON, RAW or mnemonic)
--account RAW_KEY Use a private key (insecure *)
--account 'MNEMONIC' Use a mnemonic (insecure *)
--account - Use secure entry for a raw key or mnemonic
--account-void ADDRESS Use an address as a void signer
--account-void ENS_NAME Add the resolved address as a void signer
--account-rpc ADDRESS Add the address from a JSON-RPC provider
--account-rpc INDEX Add the index from a JSON-RPC provider
--mnemonic-password Prompt for a password for mnemonics
--xxx-mnemonic-password Prompt for a (experimental) hard password
PROVIDER OPTIONS (default: all + homestead)
--alchemy Include Alchemy
--etherscan Include Etherscan
--infura Include INFURA
--nodesmith Include nodesmith
--rpc URL Include a custom JSON-RPC
--offline Dump signed transactions (no send)
--network NETWORK Network to connect to (default: homestead)
TRANSACTION OPTIONS (default: query network)
--gasPrice GWEI Default gas price for transactions(in wei)
--gasLimit GAS Default gas limit for transactions
--nonce NONCE Initial nonce for the first transaction
--yes Always accept Siging and Sending
OTHER OPTIONS
--wait Wait until transactions are mined
--debug Show stack traces for errors
--help Show this usage and exit
--version Show this version and exit
(*) By including mnemonics or private keys on the command line they are
possibly readable by other users on your system and may get stored in
your bash history file. This is NOT recommended.
_subsection: Examples

View File

@@ -1,65 +0,0 @@
Usage:
ethers [ COMMAND ] [ ARGS ] [ OPTIONS ]
COMMANDS (default: sandbox)
sandbox Run a REPL VM environment with ethers
init FILENAME Create a new JSON wallet
[ --force ] Overwrite any existing files
fund TARGET Fund TARGET with testnet ether
info [ TARGET ... ] Dump info for accounts, addresses and ENS names
send TARGET ETHER Send ETHER ether to TARGET form accounts[0]
[ --allow-zero ] Allow sending to the address zero
[ --data DATA ] Include data in the transaction
sweep TARGET Send all ether from accounts[0] to TARGET
sign-message MESSAGE Sign a MESSAGE with accounts[0]
[ --hex ] The message content is hex encoded
eval CODE Run CODE in a VM with ethers
run FILENAME Run FILENAME in a VM with ethers
wait HASH Wait for a transaction HASH to be mined
wrap-ether VALUE Deposit VALUE into Wrapped Ether (WETH)
unwrap-ether VALUE Withdraw VALUE from Wrapped Ether (WETH)
send-token TOKEN ADDRESS VALUE
Send VALUE tokens (at TOKEN) to ADDRESS
compile FILENAME Compiles a Solidity contract
[ --no-optimize ] Do not optimize the compiled output
[ --warnings ] Error on any warning
deploy FILENAME Compile and deploy a Solidity contract
[ --no-optimize ] Do not optimize the compiled output
[ --contract NAME ] Specify the contract to deploy
ACCOUNT OPTIONS
--account FILENAME Load from a file (JSON, RAW or mnemonic)
--account RAW_KEY Use a private key (insecure *)
--account 'MNEMONIC' Use a mnemonic (insecure *)
--account - Use secure entry for a raw key or mnemonic
--account-void ADDRESS Use an address as a void signer
--account-void ENS_NAME Add the resolved address as a void signer
--account-rpc ADDRESS Add the address from a JSON-RPC provider
--account-rpc INDEX Add the index from a JSON-RPC provider
--mnemonic-password Prompt for a password for mnemonics
--xxx-mnemonic-password Prompt for a (experimental) hard password
PROVIDER OPTIONS (default: all + homestead)
--alchemy Include Alchemy
--etherscan Include Etherscan
--infura Include INFURA
--nodesmith Include nodesmith
--rpc URL Include a custom JSON-RPC
--offline Dump signed transactions (no send)
--network NETWORK Network to connect to (default: homestead)
TRANSACTION OPTIONS (default: query network)
--gasPrice GWEI Default gas price for transactions(in wei)
--gasLimit GAS Default gas limit for transactions
--nonce NONCE Initial nonce for the first transaction
--yes Always accept Siging and Sending
OTHER OPTIONS
--wait Wait until transactions are mined
--debug Show stack traces for errors
--help Show this usage and exit
--version Show this version and exit
(*) By including mnemonics or private keys on the command line they are
possibly readable by other users on your system and may get stored in
your bash history file. This is NOT recommended.

View File

@@ -1,14 +0,0 @@
/home/ethers> ethers init wallet.json
Creating a new JSON Wallet - wallet.json
Keep this password and file SAFE!! If lost or forgotten
it CANNOT be recovered, by ANYone, EVER.
Choose a password: ******
Confirm password: ******
Encrypting... 100%
New account address: 0x485bcC23ae2E5038ec7ec9b8DCB2A6A6291cC003
Saved: wallet.json
# If you are planning to try out the Ropsten testnet...
/home/ethers> ethers --network ropsten fund 0x485bcC23ae2E5038ec7ec9b8DCB2A6A6291cC003
Transaction Hash: 0x8dc55b8f8dc8076acded97f9e3ed7d6162460c0221e2769806006b6d7d1156e0

View File

@@ -1,8 +0,0 @@
/home/ricmoo> ethers --account mnemonic.txt --xxx-mnemonic-password
Password (mnemonic; experimental - hard): ******
Decrypting... 100%
network: homestead (chainId: 1)
homestead> accounts[0].getAddress()
<Promise id=0 resolved>
'0x56FC8792cC17971C19bEC4Ced978beEA44711EeD'
homestead>

View File

@@ -1,7 +0,0 @@
/home/ricmoo> ethers --account public-mnemonic.txt --mnemonic-password
Password (mnemonic): ******
network: homestead (chainId: 1)
homestead> accounts[0].getAddress()
<Promise id=0 resolved>
'0x6d3F723EC1B73141AA4aC248c3ab34A5a1DAD776'
homestead>

View File

@@ -1,19 +0,0 @@
# Get the formatted balance of an account
/home/ethers> ethers --network ropsten --account wallet.json eval 'accounts[0].getBalance().then(b => formatEther(b))'
3.141592653589793238
# Get the current block number
/home/ethers> ethers --network rinkeby eval "provider.getBlockNumber()"
5761009
# Convert a Solidity signature to JSON
/home/ethers> ethers eval 'utils.Fragment.from("function balanceOf(address owner) view returns (uint)").format("json")'
{"type":"function","name":"balanceOf","constant":true,"stateMutability":"view","payble":false,"inputs":[{"type":"address","name":"owner"}],"ouputs":[{"type":"uint256"}]}
# Compute a topic hash
/home/ricmoo> ethers eval 'id("Transfer(address,address,uint256")'
0xd99659a21de82e379975ce8df556f939a4ccb95e92144f38bb0dd35730ffcdd5
# Create a random mnemonic
/home/ricmoo> ethers eval 'Wallet.createRandom().mnemonic'
useful pond inch knock ritual matrix giggle attend dilemma convince coach amazing

View File

@@ -1,44 +0,0 @@
# Sending ether
/home/ricmoo> ethers --account wallet.json send ricmoo.firefly.eth 0.123
Password (wallet.json): ******
Decrypting... 100%
Transaction:
To: 0x8ba1f109551bD432803012645Ac136ddd64DBA72
From: 0xaB7C8803962c0f2F5BBBe3FA8bf41cd82AA1923C
Value: 0.123 ether
Nonce: 96
Data: 0x
Gas Limit: 21000
Gas Price: 1.2 gwei
Chain ID: 1
Network: homestead
Send Transaction? (y/N/a) y
Response:
Hash: 0xc4adf8b379033d7ab679d199aa35e6ceee9a802ca5ab0656af067e911c4a589a
# Sending a token (SAI)
# NOTE: the contract address could be used instead but
# popular token contract addresses are also managed
# by ethers
/home/ricmoo> ethers --account wallet.json send-token sai.tokens.ethers.eth ricmoo.firefly.eth 1.0
Sending Tokens:
To: 0x8ba1f109551bD432803012645Ac136ddd64DBA72
Token Contract: 0x89d24A6b4CcB1B6fAA2625fE562bDD9a23260359
Value: 1.0
Password (wallet.json): ******
Decrypting... 100%
Transaction:
To: 0x89d24A6b4CcB1B6fAA2625fE562bDD9a23260359
From: 0xaB7C8803962c0f2F5BBBe3FA8bf41cd82AA1923C
Value: 0.0 ether
Nonce: 95
Data: 0xa9059cbb0000000000000000000000008ba1f109551bd432803012645ac136ddd64dba720000000000000000000000000000000000000000000000000de0b6b3a7640000
Gas Limit: 37538
Gas Price: 1.0 gwei
Chain ID: 1
Network: homestead
Send Transaction? (y/N/a) y
Response:
Hash: 0xd609ecb7e3b5e8d36fd781dffceede3975ece6774b6322ea56cf1e4d0a17e3a1

View File

@@ -1,14 +0,0 @@
/home/ethers> ethers --account wallet.json sign-message 'Hello World'
Password (wallet.json): ******
Decrypting... 100%
Message:
Message: "Hello World"
Message (hex): 0x48656c6c6f20576f726c64
Sign Message? (y/N/a) y
Signature
Flat: 0xca3f0b32a22a5ab97ca8be7e4a36b1e81d565c6822465d769f4faa4aa24539fb122ee5649c8a37c9f5fc8446593674159e3a7b039997cd6ee697a24b787b1a161b
r: 0xca3f0b32a22a5ab97ca8be7e4a36b1e81d565c6822465d769f4faa4aa24539fb
s: 0x122ee5649c8a37c9f5fc8446593674159e3a7b039997cd6ee697a24b787b1a16
vs: 0x122ee5649c8a37c9f5fc8446593674159e3a7b039997cd6ee697a24b787b1a16
v: 27
recid: 0

View File

@@ -9,21 +9,163 @@ of the ethers utilities already exposed.
_subsection: Help
_code: ethers-help.txt
_code: @lang<text>
Usage:
ethers [ COMMAND ] [ ARGS ] [ OPTIONS ]
COMMANDS (default: sandbox)
sandbox Run a REPL VM environment with ethers
init FILENAME Create a new JSON wallet
[ --force ] Overwrite any existing files
fund TARGET Fund TARGET with testnet ether
info [ TARGET ... ] Dump info for accounts, addresses and ENS names
send TARGET ETHER Send ETHER ether to TARGET form accounts[0]
[ --allow-zero ] Allow sending to the address zero
[ --data DATA ] Include data in the transaction
sweep TARGET Send all ether from accounts[0] to TARGET
sign-message MESSAGE Sign a MESSAGE with accounts[0]
[ --hex ] The message content is hex encoded
eval CODE Run CODE in a VM with ethers
run FILENAME Run FILENAME in a VM with ethers
wait HASH Wait for a transaction HASH to be mined
wrap-ether VALUE Deposit VALUE into Wrapped Ether (WETH)
unwrap-ether VALUE Withdraw VALUE from Wrapped Ether (WETH)
send-token TOKEN ADDRESS VALUE
Send VALUE tokens (at TOKEN) to ADDRESS
compile FILENAME Compiles a Solidity contract
[ --no-optimize ] Do not optimize the compiled output
[ --warnings ] Error on any warning
deploy FILENAME Compile and deploy a Solidity contract
[ --no-optimize ] Do not optimize the compiled output
[ --contract NAME ] Specify the contract to deploy
ACCOUNT OPTIONS
--account FILENAME Load from a file (JSON, RAW or mnemonic)
--account RAW_KEY Use a private key (insecure *)
--account 'MNEMONIC' Use a mnemonic (insecure *)
--account - Use secure entry for a raw key or mnemonic
--account-void ADDRESS Use an address as a void signer
--account-void ENS_NAME Add the resolved address as a void signer
--account-rpc ADDRESS Add the address from a JSON-RPC provider
--account-rpc INDEX Add the index from a JSON-RPC provider
--mnemonic-password Prompt for a password for mnemonics
--xxx-mnemonic-password Prompt for a (experimental) hard password
PROVIDER OPTIONS (default: all + homestead)
--alchemy Include Alchemy
--etherscan Include Etherscan
--infura Include INFURA
--nodesmith Include nodesmith
--rpc URL Include a custom JSON-RPC
--offline Dump signed transactions (no send)
--network NETWORK Network to connect to (default: homestead)
TRANSACTION OPTIONS (default: query network)
--gasPrice GWEI Default gas price for transactions(in wei)
--gasLimit GAS Default gas limit for transactions
--nonce NONCE Initial nonce for the first transaction
--yes Always accept Siging and Sending
OTHER OPTIONS
--wait Wait until transactions are mined
--debug Show stack traces for errors
--help Show this usage and exit
--version Show this version and exit
(*) By including mnemonics or private keys on the command line they are
possibly readable by other users on your system and may get stored in
your bash history file. This is NOT recommended.
_subsection: Examples
_heading: Creating Wallets @<cliex-init>
_code: ethers-init.txt
_code: @lang<shell>
/home/ethers> ethers init wallet.json
Creating a new JSON Wallet - wallet.json
Keep this password and file SAFE!! If lost or forgotten
it CANNOT be recovered, by ANYone, EVER.
Choose a password: ******
Confirm password: ******
Encrypting... 100%
New account address: 0x485bcC23ae2E5038ec7ec9b8DCB2A6A6291cC003
Saved: wallet.json
# If you are planning to try out the Ropsten testnet...
/home/ethers> ethers --network ropsten fund 0x485bcC23ae2E5038ec7ec9b8DCB2A6A6291cC003
Transaction Hash: 0x8dc55b8f8dc8076acded97f9e3ed7d6162460c0221e2769806006b6d7d1156e0
_heading: Sending Ether and Tokens @<cliex-send>
_code: ethers-send.txt
_code: @lang<shell>
# Sending ether
/home/ricmoo> ethers --account wallet.json send ricmoo.firefly.eth 0.123
Password (wallet.json): ******
Decrypting... 100%
Transaction:
To: 0x8ba1f109551bD432803012645Ac136ddd64DBA72
From: 0xaB7C8803962c0f2F5BBBe3FA8bf41cd82AA1923C
Value: 0.123 ether
Nonce: 96
Data: 0x
Gas Limit: 21000
Gas Price: 1.2 gwei
Chain ID: 1
Network: homestead
Send Transaction? (y/N/a) y
Response:
Hash: 0xc4adf8b379033d7ab679d199aa35e6ceee9a802ca5ab0656af067e911c4a589a
# Sending a token (SAI)
# NOTE: the contract address could be used instead but
# popular token contract addresses are also managed
# by ethers
/home/ricmoo> ethers --account wallet.json send-token sai.tokens.ethers.eth ricmoo.firefly.eth 1.0
Sending Tokens:
To: 0x8ba1f109551bD432803012645Ac136ddd64DBA72
Token Contract: 0x89d24A6b4CcB1B6fAA2625fE562bDD9a23260359
Value: 1.0
Password (wallet.json): ******
Decrypting... 100%
Transaction:
To: 0x89d24A6b4CcB1B6fAA2625fE562bDD9a23260359
From: 0xaB7C8803962c0f2F5BBBe3FA8bf41cd82AA1923C
Value: 0.0 ether
Nonce: 95
Data: 0xa9059cbb0000000000000000000000008ba1f109551bd432803012645ac136ddd64dba720000000000000000000000000000000000000000000000000de0b6b3a7640000
Gas Limit: 37538
Gas Price: 1.0 gwei
Chain ID: 1
Network: homestead
Send Transaction? (y/N/a) y
Response:
Hash: 0xd609ecb7e3b5e8d36fd781dffceede3975ece6774b6322ea56cf1e4d0a17e3a1
_heading: Signing Messages @<cliex-signing>
_code: ethers-sign.txt
_code: @lang<shell>
/home/ethers> ethers --account wallet.json sign-message 'Hello World'
Password (wallet.json): ******
Decrypting... 100%
Message:
Message: "Hello World"
Message (hex): 0x48656c6c6f20576f726c64
Sign Message? (y/N/a) y
Signature
Flat: 0xca3f0b32a22a5ab97ca8be7e4a36b1e81d565c6822465d769f4faa4aa24539fb122ee5649c8a37c9f5fc8446593674159e3a7b039997cd6ee697a24b787b1a161b
r: 0xca3f0b32a22a5ab97ca8be7e4a36b1e81d565c6822465d769f4faa4aa24539fb
s: 0x122ee5649c8a37c9f5fc8446593674159e3a7b039997cd6ee697a24b787b1a16
vs: 0x122ee5649c8a37c9f5fc8446593674159e3a7b039997cd6ee697a24b787b1a16
v: 27
recid: 0
_heading: Scripting @<cliex-scripting>
@@ -31,7 +173,28 @@ The ``eval`` command can be used to execute simple one-line scripts from
the command line to be passed into other commands or stored in script
environment variables.
_code: ethers-script.txt
_code: @lang<shell>
# Get the formatted balance of an account
/home/ethers> ethers --network ropsten --account wallet.json eval 'accounts[0].getBalance().then(b => formatEther(b))'
3.141592653589793238
# Get the current block number
/home/ethers> ethers --network rinkeby eval "provider.getBlockNumber()"
5761009
# Convert a Solidity signature to JSON
/home/ethers> ethers eval 'utils.Fragment.from("function balanceOf(address owner) view returns (uint)").format("json")'
{"type":"function","name":"balanceOf","constant":true,"stateMutability":"view","payble":false,"inputs":[{"type":"address","name":"owner"}],"ouputs":[{"type":"uint256"}]}
# Compute a topic hash
/home/ricmoo> ethers eval 'id("Transfer(address,address,uint256")'
0xd99659a21de82e379975ce8df556f939a4ccb95e92144f38bb0dd35730ffcdd5
# Create a random mnemonic
/home/ricmoo> ethers eval 'Wallet.createRandom().mnemonic'
useful pond inch knock ritual matrix giggle attend dilemma convince coach amazing
_heading: Using Mnemonics (with a password) @<cliex-mnemonicpassword>
@@ -40,7 +203,16 @@ string (i.e. ``""``) as the password. If you have a password on your
mnemonic, the ``-\-mnemonic-password`` will prompt for the password to
use to decrypt the account.
_code: ethers-mnemonic.txt
_code: @lang<shell>
/home/ricmoo> ethers --account public-mnemonic.txt --mnemonic-password
Password (mnemonic): ******
network: homestead (chainId: 1)
homestead> accounts[0].getAddress()
<Promise id=0 resolved>
'0x6d3F723EC1B73141AA4aC248c3ab34A5a1DAD776'
homestead>
_heading: Using Mnemonics (with experimental memory-hard passwords) @<cliex-mnemonicpassword-xxx>
@@ -50,7 +222,16 @@ the password through the [scrypt](link-wiki-scrypt)
//password-based key derivation function// first, which is intentionally slow and makes
a brute-force attack far more difficult.
_code: ethers-mnemonic-hard.txt
_code: @lang<shell>
/home/ricmoo> ethers --account mnemonic.txt --xxx-mnemonic-password
Password (mnemonic; experimental - hard): ******
Decrypting... 100%
network: homestead (chainId: 1)
homestead> accounts[0].getAddress()
<Promise id=0 resolved>
'0x56FC8792cC17971C19bEC4Ced978beEA44711EeD'
homestead>
_warning: Note
This is still an experimental feature (hence the ``xxx``).

View File

@@ -1,10 +0,0 @@
/home/ethers> ethers --account wallet.json --yes send ricmoo.eth 1.0
# An Option ----------^ ^ ^
# - name = "account" | |
# - value = "wallet.json" | |
# A Flag -----------------------------------+ |
# - name = "yes" |
# - value = true |
# Arguments ------------------------------------+
# - count = 3
# - [ "send", "ricmoo.eth", "1.0" ]

View File

@@ -114,7 +114,20 @@ _subsection: ArgParser @<cli-argparser> @SRC<cli:class.ArgParser>
The **ArgParser** is used to parse a command line into flags, options
and arguments.
_code: plugin.txt
_code: @lang<shell>
/home/ethers> ethers --account wallet.json --yes send ricmoo.eth 1.0
# An Option ----------^ ^ ^
# - name = "account" | |
# - value = "wallet.json" | |
# A Flag -----------------------------------+ |
# - name = "yes" |
# - value = true |
# Arguments ------------------------------------+
# - count = 3
# - [ "send", "ricmoo.eth", "1.0" ]
_null:
Flags are simple binary options (such as the ``--yes``), which are true if present
otherwise false.

View File

@@ -1,19 +0,0 @@
Usage:
ethers-ts FILENAME [ ... ] [ OPTIONS ]
OPTIONS
--output FILENAME Write the output to FILENAME (default: stdout)
--force Overwrite files if they already exist
--no-optimize Do not run the solc optimizer
--no-bytecode Do not include bytecode and Factory methods
OTHER OPTIONS
--debug Show stack traces for errors
--help Show this usage and exit
--version Show this version and exit
(*) By including mnemonics or private keys on the command line they are
possibly readable by other users on your system and may get stored in
your bash history file. This is NOT recommended.

View File

@@ -2,7 +2,26 @@ _section: TypeScript
_subsection: Help
_code: typescript-help.txt
_code: @lang<text>
Usage:
ethers-ts FILENAME [ ... ] [ OPTIONS ]
OPTIONS
--output FILENAME Write the output to FILENAME (default: stdout)
--force Overwrite files if they already exist
--no-optimize Do not run the solc optimizer
--no-bytecode Do not include bytecode and Factory methods
OTHER OPTIONS
--debug Show stack traces for errors
--help Show this usage and exit
--version Show this version and exit
(*) By including mnemonics or private keys on the command line they are
possibly readable by other users on your system and may get stored in
your bash history file. This is NOT recommended.
_subsection: Examples

View File

@@ -1,4 +1,4 @@
_section: Concepts
_section: Ethereum Basics
This is a very breif overview of some aspects of //Ethereum//
and blockchains which developers can make use of or should
@@ -7,3 +7,4 @@ be aware of.
_toc:
events
gas
security

View File

@@ -0,0 +1,85 @@
_section: Security
_subsection: Key Derivation Functions @<security-pbkdf>
This is not specific to Ethereum, but is a useful technique
to understand and has some implications on User Experience.
Many people are concerned that encrypting and decrypting an
Ethereum wallet is quite slow and can take quite some time.
It is important to understand this is intentional and provides
much stronger security.
The algorithm usually used for this process is [scrypt](link-wiki-scrypt),
which is a memory and CPU intensive algorithm which computes
a key (fixed-length psudo-random series of bytes) for a given
password.
_heading: Why does it take so long?
The goal is to use as much CPU and memory as possible during
this algorithm, so that a single computer can only compute a
very small number of results for some fixed amount of time. To
scale up an attack, the attacker requires additional compuers,
increasing the cost to [brute-force attack](link-wiki-bruteforce)
to guess the password.
For example, if a user knows their correct password, this process
may take 10 seconds for them to unlock their own wallet and proceed.
But since an attacker does not know the password, they must guess; and
each guess also requires 10 seconds. So, if they wish to try guessing 1
million passwords, their computer would be completely tied up for 10
million seconds, or around 115 days.
Without using an algorithm like this, a user would be able
to log in instantly, however, 1 million passwords would only
take a few seconds to attempt. Even secure passwords would
likely be broken within a short period of time. There is no way
the algorithm can be faster for a legitimate user without also
being faster for an attacker.
_heading: Mitigating the User Experience
Rather than reducing the security (see below), a better practice is to make
the user feel better about waiting. The Ethers encryption and decryption
API allows the developer to incorporate a progress bar, by passing in a
progress callback which will be periodically called with a number between
0 and 1 indication percent completion.
In general a progress bar makes the experience feel faster, as well as
more comfortable since there is a clear indication how much (relative) time
is remaining. Additionally, using language like //"decrpyting..."// in
a progress bar makes a user feel like there time is not being //needlessly//
wasted.
_heading: Work-Arounds (not recommended)
There are ways to reduce the time required to decrypt an Ethereum JSON
Wallet, but please keep in mind that doing so **discards nearly all security**
on that wallet.
The scrypt algorithm is designed to be tuned. The main purpose of this is
to increase the difficulty as time goes on and computers get faster, but
it can also be tuned down in situations where the security is less important.
_code: @LANG<javascript>
// Our wallet object
const wallet = Wallet.createRandom();
// The password to encrypt with
const password = "password123";
// WARNING: Doing this substantially reduces the security
// of the wallet. This is highly NOT recommended.
// We override the default scrypt.N value, which is used
// to indicate the difficulty to crack this wallet.
const json = wallet.encrypt(password, {
scrypt: {
// The number must be a power of 2 (default: 131072)
N: 64
}
});

View File

@@ -115,19 +115,49 @@ const getSourceUrl = (function(path, include, exclude) {
}
})("../packages/", new RegExp("packages/.*/src.ts/.*\.ts$"), new RegExp("/node_modules/|src.ts/.*browser.*"));
function codeContextify(context) {
const ethers = context.require("./packages/ethers");
context.ethers = ethers;
context.BigNumber = ethers.BigNumber;
context.constants = ethers.constants;
context.utils = ethers.utils;
context.arrayify = ethers.utils.arrayify;
context.hexlify = ethers.utils.hexlify;
context.hexValue = ethers.utils.hexValue;
context.Wallet = ethers.Wallet;
context._inspect = function(value) {
if (context.BigNumber.isBigNumber(value)) {
return `{ BigNumber: ${ JSON.stringify(value.toString()) } }`;
}
if (value && typeof(value.length) === "number" && typeof(value) !== "string") {
return "[ " + Array.prototype.map.call(value, (i) => context._inspect(i)).join(", ") + " ]";
}
return JSON.stringify(value);
}
}
module.exports = {
title: "ethers",
subtitle: "v5.0-beta",
logo: "logo.svg",
link: "https://docs-beta.ethers.io",
copyright: "The content of this site is licensed under the [Creative Commons Attribution 4.0 International License](https://choosealicense.com/licenses/cc-by-4.0/).",
markdown: {
"banner": "-----\n\nDocumentation: [html](https://docs-beta.ethers.io/)\n\n-----\n\n"
},
codeContextify: codeContextify,
getSourceUrl: getSourceUrl,
codeRoot: "../",
externalLinks: {
"link-alchemy": "https:/\/alchemyapi.io",
"link-cloudflare": "https:/\/developers.cloudflare.com/distributed-web/ethereum-gateway/",
@@ -141,6 +171,7 @@ module.exports = {
"link-metamask": "https:/\/metamask.io/",
"link-parity": "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": "https:/\/www.sphinx-doc.org/",
@@ -170,11 +201,13 @@ module.exports = {
"link-eip-191": { name: "EIP-191", url: "https:/\/eips.ethereum.org/EIPS/eip-191" },
"link-eip-609": "https:/\/eips.ethereum.org/EIPS/eip-609",
"link-eip-1014": "https:/\/eips.ethereum.org/EIPS/eip-1014",
"link-eip-1193": { name: "EIP-1193", url: "https:/\/eips.ethereum.org/EIPS/eip-1193" },
"link-eip-2098": "https:/\/eips.ethereum.org/EIPS/eip-2098",
"link-bip-39": "https://en.bitcoin.it/wiki/BIP_0039",
"link-bip-32": "https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki",
"link-npm-elliptic": { name: "elliptic", url: "https:/\/www.npmjs.com/package/elliptic" },
"link-npm-events": { name: "EventEmitter", url: "https:/\/nodejs.org/dist/latest-v13.x/docs/api/events.html#events_class_eventemitter" },
"link-npm-bnjs": { name: "BN.js", url: "https:/\/www.npmjs.com/package/bn.js" },
"link-npm-query-bignumber": "https:/\/www.npmjs.com/search?q=bignumber",
@@ -189,7 +222,9 @@ module.exports = {
"link-wiki-basicauth": { name: "Basic Authentication", url: "https:/\/en.wikipedia.org/wiki/Basic_access_authentication" },
"link-wiki-backoff": { name: "Exponential Backoff", url: "https:/\/en.wikipedia.org/wiki/Exponential_backoff" },
"link-wiki-bloomfilter": { name: "Bloom Filter", url: "https:/\/en.wikipedia.org/wiki/Bloom_filter" },
"link-wiki-bruteforce": "https:/\/en.wikipedia.org/wiki/Brute-force_attack",
"link-wiki-cryptographichash": "https:/\/en.wikipedia.org/wiki/Cryptographic_hash_function",
"link-wiki-ecrecover": { name: "ECDSA Public Key Recovery", url: "https:/\/en.wikipedia.org/wiki/Elliptic_Curve_Digital_Signature_Algorithm#Public_key_recovery" },
"link-wiki-homoglyph": "https:/\/en.wikipedia.org/wiki/IDN_homograph_attack",
"link-wiki-hmac": "https:/\/en.wikipedia.org/wiki/HMAC",
"link-wiki-iban": "https:/\/en.wikipedia.org/wiki/International_Bank_Account_Number",

View File

@@ -18,7 +18,17 @@ itself have body.
_heading: Directive Format
_code: fragment.txt
_code: @lang<text>
\_DIRECTIVE: VALUE @<LINK> @EXTENSION<PARAMETER>
BODY
DIRECTIVE: The directive name
VALUE: Optional; the value to pass to the directive
LINK: Optional; a name for internal linking
EXTENSION: Optional; extended directive functionality
PARAMETER: Optional; value to pass to extended directive functions
BODY: Optional; the directive body (certain directives only)
_heading: Flatworm Directives @<flatworm-directive>
@@ -29,16 +39,22 @@ to in //Table of Contents// and have a dividing line drawn above
them. If an option is specified, it is avaialble as a name for
intern linking. There should only be one ``_section:`` per page.
**Extensions:** @INHERIT, @SRC, @NAV, @NOTE
_definition: **_subsection:** //TITLE//
A //subsection// has its **TITLE** in an H2 font. Subsections are linked
to in //Table of Contents// and have a dividing line drawn above
them. If an option is specified, it is avaialble as a name for
internal linking.
**Extensions:** @INHERIT, @SRC, @NOTE
_definition: **_heading:** //TITLE//
A //heading// has its **TITLE** in an H3 font. If an option is specified,
it is available as a name for internal linking.
**Extensions:** @INHERIT, @SRC, @NOTE
_definition: **_definition:** //TERM//
A //definition// has its **TERM** bolded and the markdown body is
indented.
@@ -47,15 +63,18 @@ _definition: **_property:** //SIGNATURE//
A //property// has its JavaScript **SIGNATURE** formatted and the
markdown body is indented.
**Extensions:** @SRC
_definition: **_note:** //TITLE//
A //note// is placed in a blue bordered-box to draw attention to it.
_definition: **_warning:** //TITLE//
A //warning// is placed in an orange bordered-box to draw attention to it.
_definition: **_code:** //FILENAME//
A //code// reads the **FILENAME** and depending on the extension
adjusts it.
_definition: **_code:** //TITLE//
A //code// creates a code block.
**Extensions:** @LANG
For JavaScript files, the file is executed, with ``\/\/!`` replaced
with the result of the last statement and ``\/\/!error`` is replaced
@@ -75,16 +94,73 @@ used to reset the indentation.
_heading: Examples @<>
_code: examples.txt
_code: @lang<text>
\_section: Hello World @<link-to-this-section>
\_subsection: Some Example @<link-to-this-subsection>
\_heading: Large Bold Text @<link-to-this-heading>
\_definition: Flatworm
A phylum of relatively **simple** bilaterian, unsegmented,
soft-bodied invertebrates.
\_property: String.fromCharCode(code) => string
Returns a string created from //code//, a sequence of
UTF-16 code units.
\_code: heading
// Some code goes here
while(1);
\_toc:
some-file
some-directory
\_definition and reset the indentation.
\_note: Title
This is placed in a blue box.
\_warning: Title
This is placed in an orange box.
\_null:
This breaks out of a directive. For example, to end a
_subsection: Markdown @<flatworm-markdown>
The markdown is simple and does not have the flexibility of
other dialects, but allows for **bold**, //italic//,
__underlined__, ``monospaced``, ^^super-scripted^^ text,
supporting [links](flatworm-markdown) and lists.
__underlined__, ``monospaced``, super^^script^^ and ~~strike~~
text, supporting [links](flatworm-markdown) and lists.
_code: markdown.txt
_code: @lang<text>
**bold text**
//italic text//
__underlined text__
``monospace code``
^^superscript text^^
~~strikeout text~~
- This is a list
- With bullet points
- With a total of three items
This is a [Link to Ethereum](https://ethereum.org) and this
is an [Internal Link](some-link).
This is a self-titled link [[https://ethereumorg]] and this
[[some-link]] will use the title from its directives value.
_subsection: Configuration @<flatworm-config>
@@ -96,26 +172,34 @@ the top of the source folder.
TODO: example JSON and example JS
_subsection: Extended Directive Functions @<flatworm-extended-directive-functions>
_subsection: Extensions @<flatworm-extensions>
_heading: @INHERIT\<markdown>
Adds an inherits description to a directive. The //markdown// may contain links.
This extended directive function is available for:
- _section
- _subsetion
- _heading
_heading: @LANG\<text>
Set the language the code should be syntax-highlighted for. If "javascript", the
code will be evaluated.
- javascript (will be evaluated)
- script (useful for JavaScript but that should not be evaluated)
- shell
- text
_heading: @NAV\<text>
Sets the name in the breadcrumbs when not the current node.
This extended directive function is available for:
- _section
_heading: @NOTE\<markdown>
Adds a note to a directive. The //markdown// may contain links. If the directive
already has an @INHERIT extension, that will be used instead and the @NOTE will
be ignored.
_heading: @SRC\<text>
@@ -125,10 +209,3 @@ will be linked to by a link next to the //directive//.
This extended directive function requires an advanced ``config.js`` [[flatworm-config]]
file since it requires a JavaScript function.
This extended directive function is available for:
- _section
- _subsetion
- _heading
- _property

View File

@@ -1,30 +0,0 @@
_section: Hello World @<link-to-this-section>
_subsection: Some Example @<link-to-this-subsection>
_heading: Large Bold Text @<link-to-this-heading>
_definition: Flatworm
A phylum of relatively **simple** bilaterian, unsegmented,
soft-bodied invertebrates.
_property: String.fromCharCode(code) => string
Returns a string created from //code//, a sequence of
UTF-16 code units.
_code: filename.js
_toc:
some-file
some-directory
_definition and reset the indentation.
_note: Title
This is placed in a blue box.
_warning: Title
This is placed in an orange box.
_null:
This breaks out of a directive. For example, to end a

View File

@@ -1,9 +0,0 @@
_DIRECTIVE: VALUE @<LINK> @META<PARAMETER>
BODY
DIRECTIVE: The directive name
VALUE: Optional; the value to pass to the directive
LINK: Optional; a name for internal linking
META: Optional; extended directive functionality
PARAMETER: Optional; value to pass to extended directive functions
BODY: Optional; the directive body (certain directives only)

View File

@@ -1,23 +0,0 @@
**bold text**
//italic text//
__underlined text__
``monospace code``
^^superscript text^^
- This is a list
- With bullet points
- With a total of three items
This is separated by -- an en-dash.
This is separated by --- an em-dash.
This is a [Link to Ethereum](https://ethereum.org) and this
is an [Internal Link](some-link).
This is a self-titled link [[https://ethereumorg]] and this
[[some-link]] will use the title from its directives value.

View File

@@ -8,14 +8,23 @@ manually from sub-packages under the [@ethersproject](link-ethers-npm)
but for most projects, the umbrella package is the easiest way to
get started.
_code: installing.txt
_code: @lang<shell>
/home/ricmoo> npm install --save ethers@next
_subsection: Importing
_heading: Node.js
_code: importing-node.source
_code: @lang<script>
// CommonJS
const { ethers } = require("ethers");
// ES6 or TypeScript
import { ethers } from "ethers";
_heading: Web Browser
@@ -26,4 +35,7 @@ yourself.
For quick demos or prototyping though, it can be loaded in your
Web Applications from our CDN.
_code: importing-browser.txt
_code: @lang<html>
<script src="https://cdn.ethers.io/lib/ethers-5.0.esm.min.js"
type="application/javascipt"></script>

View File

@@ -1,2 +0,0 @@
<script src="https://cdn.ethers.io/lib/ethers-5.0.esm.min.js"
type="application/javascipt"></script>

View File

@@ -1,5 +0,0 @@
// CommonJS
const { ethers } = require("ethers");
// ES6 or TypeScript
const { ethers } = require("ethers");

View File

@@ -46,7 +46,7 @@ _toc:
contributing
documentation
license
_subsection: Legacy Documentation

View File

@@ -1 +0,0 @@
/home/ricmoo> npm install --save ethers@next

View File

@@ -0,0 +1,206 @@
_section: Migration: From Ethers v4 @<migration-v4>
_subsection: BigNumber
_heading: Namespace
Since [[bignumber]] is used quite frequently, it has been moved to
the top level of the umbrella package.
_code: @lang<script>
// v4
ethers.utils.BigNumber
ethers.utils.BigNumberish
// v5
ethers.BigNumber
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
``from`` class method.
_code: @lang<script>
// v4
new ethers.utils.BigNumber(someValue)
ethers.utils.bigNumberify(someValue);
// v5
// - Constructor is private
// - Removed `bigNumberify`
ethers.BigNumber.from(someValue)
_subsection: Contracts
_code: @lang<script>
// @TODO
_subsection: Errors
_heading: Namespace
All errors now belong to the [[logger]] class and the related functions
have been moved to [[logger]] instances, which can include a per-package
version string.
Global error fucntions have been moved [[logger]] class methods.
_code: @lang<script>
// v4
ethers.errors.UNKNOWN_ERROR
ethers.errors.*
errors.setCensorship(censorship, permanent)
errors.setLogLevel(logLevel)
errors.checkArgumentCount(count, expectedCount, suffix)
errors.checkNew(self, kind)
errors.checkNormalize()
errors.throwError(message, code, params)
errors.warn(...)
errors.info(...)
// v5
ethers.utils.Logger.errors.UNKNOWN_ERROR
ethers.utils.Logger.errors.*
Logger.setCensorship(censorship, permanent)
Logger.setLogLevel(logLevel)
const logger = new ethers.utils.Logger(version);
logger.checkArgumentCount(count, expectedCount, suffix)
logger.checkNew(self, kind)
logger.checkNormalize()
logger.throwError(message, code, params)
logger.warn(...)
logger.info(...)
_subsection: Interface
The [[abi-interface]] object has undergone the most dramatic changes.
It is no longer a meta-class and now has methods that simplify handling
contract interface operations without the need for object inspection and
special edge cases.
_heading: Functions
_code: @lang<script>
// v4 (example: "transfer(address to, uint amount)")
interface.functions.transfer.encode(to, amount)
interface.functions.transfer.decode(callData)
// v5
interface.encodeData("transfer", [ to, amount ])
interface.decodeResult("transfer", data)
// Or you can use any compatible signature or Fragment objects.
// Notice that signature normalization is performed for you,
// e.g. "uint" and "uint256" will be automatically converted
interface.encodeData("transfer(address,uint)", [ to, amount ])
interface.decodeResult("transfer(address to, uint256 amount)", data)
_heading: Events
_code: @lang<script>
// v4 (example: Transfer(address indexed, address indexed, uint256)
interface.events.Transfer.encodeTopics(values)
interface.events.Transfer.decode(data, topics)
// v5
interface.encodeFilterTopics("Transfer", values)
interface.encodeEventLog("Transfer", data, topics)
_heading: Inspection
Interrogating properties about a function or event can now (mostly) be
done directly on the [[abi-fragment]] object.
_code:
// v4
interface.functions.transfer.name
interface.functions.transfer.inputs
interface.functions.transfer.outputs
interface.functions.transfer.payable
interface.functions.transfer.gas
// v5
const functionFragment = interface.getFunction("transfer")
functionFragment.name
functionFragment.inputs
functionFragment.outputs
functionFragment.payable
functionFragment.gas
// v4; type is "call" or "transaction"
interface.functions.transfer.type
// v5; constant is true (i.e. "call") or false (i.e. "transaction")
functionFragment.constant
// v4
interface.events.Transfer.anonymous
interface.events.Transfer.inputs
interface.events.Transfer.name
// v5
const eventFragment = interface.getEvent("Transfer");
eventFragment.anonymous
eventFragment.inputs
eventFragment.name
// v4
const functionSig = interface.functions.transfer.signature
const sighash = interface.functions.transfer.sighash
const eventSig = interface.events.Transfer.signature
const topic = interface.events.Transfer.topic
// v5
const functionSig = functionFragment.format()
const sighash = interface.getSighash(functionFragment)
const eventSig = eventFragment.format()
const topic = interface.getTopic(eventFragment)
_subsection: Utilities
_heading: Renaming
_code: @lang<script>
// @TODO
_subsection: Wallet
_heading: Mnemonic Phrases
The **mnemonic** phrase and related properties have been merged into
a single ``mnemonic`` object, which also now includes the ``locale``.
_code: @lang<script>
// v4
wallet.mnemonic
wallet.path
// v5
// - Mnemonic phrase and path are a Mnemonic object
// - Note: wallet.mnemonic is null if there is no mnemonic
wallet.mnemonic.phrase
wallet.mnemonic.path

View File

@@ -1,8 +0,0 @@
// v4
new ethers.utils.BigNumber(someValue)
ethers.utils.bigNumberify(someValue);
// v5
// - Constructor is private
// - Removed `bigNumberify`
ethers.BigNumber.from(someValue)

View File

@@ -1,7 +0,0 @@
// v4
ethers.utils.BigNumber
ethers.utils.BigNumberish
// v5
ethers.BigNumber
ethers.BigNumberish

View File

@@ -1 +0,0 @@
TODO

View File

@@ -1,29 +0,0 @@
// v4
ethers.errors.UNKNOWN_ERROR
ethers.errors.*
errors.setCensorship(censorship, permanent)
errors.setLogLevel(logLevel)
errors.checkArgumentCount(count, expectedCount, suffix)
errors.checkNew(self, kind)
errors.checkNormalize()
errors.throwError(message, code, params)
errors.warn(...)
errors.info(...)
// v5
ethers.utils.Logger.errors.UNKNOWN_ERROR
ethers.utils.Logger.errors.*
Logger.setCensorship(censorship, permanent)
Logger.setLogLevel(logLevel)
const logger = new ethers.utils.Logger(version);
logger.checkArgumentCount(count, expectedCount, suffix)
logger.checkNew(self, kind)
logger.checkNormalize()
logger.throwError(message, code, params)
logger.warn(...)
logger.info(...)

View File

@@ -1,62 +0,0 @@
_section: Migration: From Ethers v4 @<migration-v4>
_subsection: BigNumber
_heading: Namespace
Since [[bignumber]] is used quite frequently, it has been moved to
the top level of the umbrella package.
_code: bignumber-namespace.txt
_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
``from`` class method.
_code: bignumber-creating.txt
_subsection: Contracts
_code: contracts.txt
_subsection: Errors
_heading: Namespace
All errors now belong to the [[logger]] class and the related functions
have been moved to [[logger]] instances, which can include a per-package
version string.
Global error fucntions have been moved [[logger]] class methods.
_code: errors.txt
_subsection: Interface
The [[abi-interface]] object has undergone the most dramatic changes.
It is no longer a meta-class and now has methods that simplify handling
contract interface operations without the need for object inspection and
special edge cases.
_heading: Functions
_code: interface-functions.txt
_heading: Events
_code: interface-events.txt
_heading: Inspection
Interrogating properties about a function or event can now (mostly) be
done directly on the [[abi-fragment]] object.
_code: interface-inspection.txt
_subsection: Utilities
_heading: Renaming
_code: utils.txt
_subsection: Wallet
_heading: Mnemonic Phrases
The **mnemonic** phrase and related properties have been merged into
a single ``mnemonic`` object, which also now includes the ``locale``.
_code: wallet.txt

View File

@@ -1,7 +0,0 @@
// v4 (example: Transfer(address indexed, address indexed, uint256)
interface.events.Transfer.encodeTopics(values)
interface.events.Transfer.decode(data, topics)
// v5
interface.encodeFilterTopics("Transfer", values)
interface.encodeEventLog("Transfer", data, topics)

View File

@@ -1,14 +0,0 @@
// v4 (example: "transfer(address to, uint amount)")
interface.functions.transfer.encode(to, amount)
interface.functions.transfer.decode(callData)
// v5
interface.encodeData("transfer", [ to, amount ])
interface.decodeResult("transfer", data)
// Or you can use any compatible signature or Fragment objects.
// Notice that signature normalization is performed for you,
// e.g. "uint" and "uint256" will be automatically converted
interface.encodeData("transfer(address,uint)", [ to, amount ])
interface.decodeResult("transfer(address to, uint256 amount)", data)

View File

@@ -1,48 +0,0 @@
// v4
interface.functions.transfer.name
interface.functions.transfer.inputs
interface.functions.transfer.outputs
interface.functions.transfer.payable
interface.functions.transfer.gas
// v5
const functionFragment = interface.getFunction("transfer")
functionFragment.name
functionFragment.inputs
functionFragment.outputs
functionFragment.payable
functionFragment.gas
// v4; type is "call" or "transaction"
interface.functions.transfer.type
// v5; constant is true (i.e. "call") or false (i.e. "transaction")
functionFragment.constant
// v4
interface.events.Transfer.anonymous
interface.events.Transfer.inputs
interface.events.Transfer.name
// v5
const eventFragment = interface.getEvent("Transfer");
eventFragment.anonymous
eventFragment.inputs
eventFragment.name
// v4
const functionSig = interface.functions.transfer.signature
const sighash = interface.functions.transfer.sighash
const eventSig = interface.events.Transfer.signature
const topic = interface.events.Transfer.topic
// v5
const functionSig = functionFragment.format()
const sighash = interface.getSighash(functionFragment)
const eventSig = eventFragment.format()
const topic = interface.getTopic(eventFragment)

View File

@@ -1 +0,0 @@
TODO

View File

@@ -1,9 +0,0 @@
// v4
wallet.mnemonic
wallet.path
// v5
// - Mnemonic phrase and path are a Mnemonic object
// - Note: wallet.mnemonic is null if there is no mnemonic
wallet.mnemonic.phrase
wallet.mnemonic.path

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
github-cache/021100f4986d Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
github-cache/02768cb22cd4 Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
github-cache/03bc8581a0f7 Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More