๐๐๐ฆโพ๏ธ๐ณ๐๐ผ๐ธ๐๐๐๐ถ๐ฆโ๏ธ๐โป
Your branch is ahead of 'origin/pos' by 1 commit.
(use "git push" to publish your local commits)
hint: You have divergent branches and need to specify how to reconcile them. hint: You can do so by running one of the following commands sometime before hint: your next pull: hint: hint: git config pull.rebase false # merge (the default strategy) hint: git config pull.rebase true # rebase hint: git config pull.ff only # fast-forward only hint: hint: You can replace "git config" with "git config --global" to set a default hint: preference for all repositories. You can also pass --rebase, --no-rebase, hint: or --ff-only on the command line to override the configured default per hint: invocation.
==> git pull git reset --hard origin/set-cl-node
remove python3.9 on ubuntu
sudo apt-get remove python3.9
ubuntu@ip-172-31-22-252:~$ git clone git@github.com:linked0/poohgeth
Cloning into 'poohgeth'... The authenticity of host 'github.com (20.200.245.247)' can't be established. ED25519 key fingerprint is SHA256:+DiY3wvvV6TuJJhbpZisF/zLDA0zPMSvHdkr4UvCOqU. This key is not known by any other names Are you sure you want to continue connecting (yes/no/[fingerprint])? yes Warning: Permanently added 'github.com' (ED25519) to the list of known hosts. git@github.com: Permission denied (publickey). fatal: Could not read from remote repository.
- ==> ssh.tar๋ฅผ ํ์๋๋ฐ, .ssh/.ssh์ ํ๋ฆฌ๋ ๋ฌธ์ ๋ฐ์ ์๋์ ๊ฐ์ด ๋ถํ์ํ๊ฒ -C์ต์ ์
- tar -xvzf ssh.tar -C .ssh
๊ธฐํ
EC2 key๋ก ssh์ ์ Permission Denied (public key)
pooh-seoul.pem๋ฅผ ์จ์ผํ๋๋ฐ tednet.pem์ ์.
solidity.md
NodeJS/TypeScript
Event ์ธ์๋ค์ค ํ๋๋ง ์ฒดํฌ
await expect(lock.withdraw())
.to.emit(lock, "Withdrawal")
.withArgs(lockedAmount, anyValue);
์ ์ฝ๋๋ฅผ ์๋์ ๊ฐ์ด ๋ณ๊ฒฝ. anyValue๊ฐ ์ ๋๋ก ๋์ ์ํจ.
const tx = await lock.withdraw();
const receipt = await tx.wait();
// Find the Withdrawal event in the transaction receipt
const withdrawalEvent = receipt.events.find((e: any) => e.event === "Withdrawal");
// Check if the Withdrawal event was emitted
expect(withdrawalEvent, "Withdrawal event should be emitted").to.not.be.undefined;
// Check only the first argument of the Withdrawal event
expect(withdrawalEvent.args[0]).to.equal(lockedAmount);
anyValue function
import { anyValue } from "@nomicfoundation/hardhat-chai-matchers/withArgs";
wait expect(lock.withdraw())
.to.emit(lock, "Withdrawal")
.withArgs(lockedAmount, anyValue); // We accept any value as when arg
:error occured like this,
AssertionError: Expected 1732243098 to equal function anyValue() {
return true;
}, but they have different lengths
an issue with fsevents
warning Error running install script for optional dependency: "/Users/hyunjaelee/node_modules/@remix-project/remixd/node_modules/fsevents: Command failed.
Exit code: 1
Command: node install.js
Arguments:
Directory: /Users/hyunjaelee/node_modules/@remix-project/remixd/node_modules/fsevents
Output:
node:events:491
throw er; // Unhandled 'error' event
^
Error: spawn node-gyp ENOENT
at Process.ChildProcess._handle.onexit (node:internal/child_process:285:19)
at onErrorNT (node:internal/child_process:485:16)
at processTicksAndRejections (node:internal/process/task_queues:83:21)
Emitted 'error' event on ChildProcess instance at:
at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)
at onErrorNT (node:internal/child_process:485:16)
at processTicksAndRejections (node:internal/process/task_queues:83:21) {
errno: -2,
code: 'ENOENT',
syscall: 'spawn node-gyp',
success Saved lockfile.
warning No license field
success Saved 568 new dependencies.
๐ ํด๊ฒฐ
- Add this to your package.json file, then re-run yarn (or yarn install): "resolutions": { "fsevents": "1.2.9" }
- ์ด๋ ๊ฒ ํ๋ฉด node-gyp๊ฐ ์ค์น๋จ
- ๊ทธ๋ฌ๊ณ ๋์ ์์ resolutions ๋ถ๋ถ์ ์ ๊ฑฐํ๊ณ ๋ค์ yarn์ ์คํํด์ fsevents๋ฅผ ์ต์ ์ผ๋ก ์ฌ์ค์น
- ์ ๊ทธ๋ฌ๋ฉด "Typeerror: fsevents.watch is not a function" ๋ฐ์ํ ์ ์์.
๋ก์ปฌ ๋งํฌ ๋ง๋ค๊ธฐ
- yarn add /Users/hyunjaelee/work/hardhat-zksync/packages/hardhat-zksync-deploy
npm module upgrade
yarn upgrade hardhat-change-network
NPM publish ์๋ฌ
npm notice Publishing to https://registry.npmjs.org/
This operation requires a one-time password.
Enter OTP: 978999
npm ERR! code E402
npm ERR! 402 Payment Required - PUT https://registry.npmjs.org/@poohnet%2fpooh-swap-v2-core - You must sign up for private packages
npm ERR! A complete log of this run can be found in:
๐ ํด๊ฒฐ npm public --access public์ ์ฌ์ฉํด์ผ ํจ.
/bin/sh: python: command not found
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
ACTION deps_sqlite3_gyp_action_before_build_target_unpack_sqlite_dep Release/obj/gen/sqlite-autoconf-3310100/sqlite3.c
/bin/sh: python: command not found
make: *** [Release/obj/gen/sqlite-autoconf-3310100/sqlite3.c] Error 127
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/Users/hyunjaelee/.nvm/versions/node/v16.20.2/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:201:23)
gyp ERR! stack at ChildProcess.emit (node:events:513:28)
gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:293:12)
gyp ERR! System Darwin 23.0.0
gyp ERR! command \"/Users/hyunjaelee/.nvm/versions/node/v16.20.2/bin/node\" \"/Users/hyunjaelee/.nvm/versions/node/v16.20.2/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js\" \"build\" \"--fallback-to-build\" \"--module=/Users/hyunjaelee/work/ondo-v1/node_modules/sqlite3/lib/binding/node-v93-darwin-x64/node_sqlite3.node\" \"--module_name=node_sqlite3\" \"--module_path=/Users/hyunjaelee/work/ondo-v1/node_modules/sqlite3/lib/binding/node-v93-darwin-x64\" \"--napi_version=8\" \"--node_abi_napi=napi\" \"--napi_build_version=0\" \"--node_napi_label=node-v93\"
gyp ERR! cwd /Users/hyunjaelee/work/ondo-v1/node_modules/sqlite3
gyp ERR! node -v v16.20.2
gyp ERR! node-gyp -v v9.1.0
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/Users/hyunjaelee/.nvm/versions/node/v16.20.2/bin/node /Users/hyunjaelee/.nvm/versions/node/v16.20.2/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/Users/hyunjaelee/work/ondo-v1/node_modules/sqlite3/lib/binding/node-v93-darwin-x64/node_sqlite3.node --module_name=node_sqlite3 --module_path=/Users/hyunjaelee/work/ondo-v1/node_modules/sqlite3/lib/binding/node-v93-darwin-x64 --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v93' (1)
node-pre-gyp ERR! stack at ChildProcess.<anonymous> (/Users/hyunjaelee/work/ondo-v1/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack at ChildProcess.emit (node:events:513:28)
node-pre-gyp ERR! stack at maybeClose (node:internal/child_process:1100:16)
node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:304:5)
node-pre-gyp ERR! System Darwin 23.0.0
node-pre-gyp ERR! command \"/Users/hyunjaelee/.nvm/versions/node/v16.20.2/bin/node\" \"/Users/hyunjaelee/work/ondo-v1/node_modules/sqlite3/node_modules/.bin/node-pre-gyp\" \"install\" \"--fallback-to-build\"
node-pre-gyp ERR! cwd /Users/hyunjaelee/work/ondo-v1/node_modules/sqlite3
node-pre-gyp ERR! node -v v16.20.2
node-pre-gyp ERR! node-pre-gyp -v v0.11.0
node-pre-gyp ERR! not ok
โจ Done in 44.12s.
โ ondo-v1 git:(main) rm -rf node_modules
โ ondo-v1 git:(main) yarn
yarn install v1.22.19
[1/4] ๐ Resolving packages...
[2/4] ๐ Fetching packages...
[3/4] ๐ Linking dependencies...
warning " > @nomiclabs/hardhat-waffle@2.0.1" has incorrect peer dependency "@nomiclabs/hardhat-ethers@^2.0.0".
warning " > @uniswap/sdk@3.0.3" has unmet peer dependency "@ethersproject/address@^5.0.0-beta".
warning " > @uniswap/sdk@3.0.3" has unmet peer dependency "@ethersproject/contracts@^5.0.0-beta".
warning " > @uniswap/sdk@3.0.3" has unmet peer dependency "@ethersproject/networks@^5.0.0-beta".
warning " > @uniswap/sdk@3.0.3" has unmet peer dependency "@ethersproject/providers@^5.0.0-beta".
warning " > @uniswap/sdk@3.0.3" has unmet peer dependency "@ethersproject/solidity@^5.0.0-beta".
warning "hardhat-gas-reporter > eth-gas-reporter@0.2.22" has unmet peer dependency "@codechecks/client@^0.1.0".
warning " > @typechain/ethers-v5@7.1.2" has unmet peer dependency "@ethersproject/bytes@^5.0.0".
warning " > @typechain/ethers-v5@7.1.2" has unmet peer dependency "@ethersproject/providers@^5.0.0".
warning " > @typechain/ethers-v5@7.1.2" has unmet peer dependency "@ethersproject/abi@^5.0.0".
warning " > hardhat-deploy@0.8.9" has unmet peer dependency "@ethersproject/hardware-wallets@^5.0.14".
warning "truffle > @truffle/db > jsondown@1.0.0" has unmet peer dependency "abstract-leveldown@*".
warning "truffle > @truffle/db > graphql-tools > @graphql-tools/links > apollo-upload-client@14.1.2" has unmet peer dependency "subscriptions-transport-ws@^0.9.0".
[4/4] ๐จ Building fresh packages...
[9/31] โ keccak
[-/31] โ waiting...
[19/31] โ fsevents
[10/31] โ secp256k1
warning Error running install script for optional dependency: "/Users/hyunjaelee/work/ondo-v1/node_modules/sqlite3: Command failed.
Exit code: 1
Command: node-pre-gyp install --fallback-to-build
Arguments:
Directory: /Users/hyunjaelee/work/ondo-v1/node_modules/sqlite3
Output:
node-pre-gyp info it worked if it ends with ok
node-pre-gyp info using node-pre-gyp@0.11.0
node-pre-gyp info using node@16.20.2 | darwin | x64
node-pre-gyp WARN Using request for node-pre-gyp https download
node-pre-gyp info check checked for \"/Users/hyunjaelee/work/ondo-v1/node_modules/sqlite3/lib/binding/node-v93-darwin-x64/node_sqlite3.node\" (not found)
node-pre-gyp http GET https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v4.2.0/node-v93-darwin-x64.tar.gz
node-pre-gyp http 403 https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v4.2.0/node-v93-darwin-x64.tar.gz
node-pre-gyp WARN Tried to download(403): https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v4.2.0/node-v93-darwin-x64.tar.gz
node-pre-gyp WARN Pre-built binaries not found for sqlite3@4.2.0 and node@16.20.2 (node-v93 ABI, unknown) (falling back to source compile with node-gyp)
node-pre-gyp http 403 status code downloading tarball https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v4.2.0/node-v93-darwin-x64.tar.gz
gyp info it worked if it ends with ok
gyp info using node-gyp@9.1.0
gyp info using node@16.20.2 | darwin | x64
gyp info ok
gyp info it worked if it ends with ok
gyp info using node-gyp@9.1.0
gyp info using node@16.20.2 | darwin | x64
gyp info find Python using Python version 3.9.6 found at \"/Library/Developer/CommandLineTools/usr/bin/python3\"
gyp info spawn /Library/Developer/CommandLineTools/usr/bin/python3
gyp info spawn args [
gyp info spawn args '/Users/hyunjaelee/.nvm/versions/node/v16.20.2/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args 'binding.gyp',
gyp info spawn args '-f',
gyp info spawn args 'make',
gyp info spawn args '-I',
gyp info spawn args '/Users/hyunjaelee/work/ondo-v1/node_modules/sqlite3/build/config.gypi',
gyp info spawn args '-I',
gyp info spawn args '/Users/hyunjaelee/.nvm/versions/node/v16.20.2/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
gyp info spawn args '-I',
gyp info spawn args '/Users/hyunjaelee/Library/Caches/node-gyp/16.20.2/include/node/common.gypi',
gyp info spawn args '-Dlibrary=shared_library',
gyp info spawn args '-Dvisibility=default',
gyp info spawn args '-Dnode_root_dir=/Users/hyunjaelee/Library/Caches/node-gyp/16.20.2',
gyp info spawn args '-Dnode_gyp_dir=/Users/hyunjaelee/.nvm/versions/node/v16.20.2/lib/node_modules/npm/node_modules/node-gyp',
gyp info spawn args '-Dnode_lib_file=/Users/hyunjaelee/Library/Caches/node-gyp/16.20.2/<(target_arch)/node.lib',
gyp info spawn args '-Dmodule_root_dir=/Users/hyunjaelee/work/ondo-v1/node_modules/sqlite3',
gyp info spawn args '-Dnode_engine=v8',
gyp info spawn args '--depth=.',
gyp info spawn args '--no-parallel',
gyp info spawn args '--generator-output',
gyp info spawn args 'build',
gyp info spawn args '-Goutput_dir=.'
gyp info spawn args ]
gyp info ok
gyp info it worked if it ends with ok
gyp info using node-gyp@9.1.0
gyp info using node@16.20.2 | darwin | x64
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
ACTION deps_sqlite3_gyp_action_before_build_target_unpack_sqlite_dep Release/obj/gen/sqlite-autoconf-3310100/sqlite3.c
/bin/sh: python: command not found
make: *** [Release/obj/gen/sqlite-autoconf-3310100/sqlite3.c] Error 127
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/Users/hyunjaelee/.nvm/versions/node/v16.20.2/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:201:23)
gyp ERR! stack at ChildProcess.emit (node:events:513:28)
gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:293:12)
gyp ERR! System Darwin 23.0.0
gyp ERR! command \"/Users/hyunjaelee/.nvm/versions/node/v16.20.2/bin/node\" \"/Users/hyunjaelee/.nvm/versions/node/v16.20.2/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js\" \"build\" \"--fallback-to-build\" \"--module=/Users/hyunjaelee/work/ondo-v1/node_modules/sqlite3/lib/binding/node-v93-darwin-x64/node_sqlite3.node\" \"--module_name=node_sqlite3\" \"--module_path=/Users/hyunjaelee/work/ondo-v1/node_modules/sqlite3/lib/binding/node-v93-darwin-x64\" \"--napi_version=8\" \"--node_abi_napi=napi\" \"--napi_build_version=0\" \"--node_napi_label=node-v93\"
gyp ERR! cwd /Users/hyunjaelee/work/ondo-v1/node_modules/sqlite3
gyp ERR! node -v v16.20.2
gyp ERR! node-gyp -v v9.1.0
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/Users/hyunjaelee/.nvm/versions/node/v16.20.2/bin/node /Users/hyunjaelee/.nvm/versions/node/v16.20.2/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/Users/hyunjaelee/work/ondo-v1/node_modules/sqlite3/lib/binding/node-v93-darwin-x64/node_sqlite3.node --module_name=node_sqlite3 --module_path=/Users/hyunjaelee/work/ondo-v1/node_modules/sqlite3/lib/binding/node-v93-darwin-x64 --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v93' (1)
node-pre-gyp ERR! stack at ChildProcess.<anonymous> (/Users/hyunjaelee/work/ondo-v1/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack at ChildProcess.emit (node:events:513:28)
node-pre-gyp ERR! stack at maybeClose (node:internal/child_process:1100:16)
node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:304:5)
node-pre-gyp ERR! System Darwin 23.0.0
node-pre-gyp ERR! command \"/Users/hyunjaelee/.nvm/versions/node/v16.20.2/bin/node\" \"/Users/hyunjaelee/work/ondo-v1/node_modules/sqlite3/node_modules/.bin/node-pre-gyp\" \"install\" \"--fallback-to-build\"
node-pre-gyp ERR! cwd /Users/hyunjaelee/work/ondo-v1/node_modules/sqlite3
node-pre-gyp ERR! node -v v16.20.2
node-pre-gyp ERR! node-pre-gyp -v v0.11.0
node-pre-gyp ERR! not ok
๐ ํด๊ฒฐ
- ํ์ด์ 3.0 ์ค์น
brew install python3
- Set python path
which python3
npm config set python /path/to/python
error work/polymath-core/node_modules/sha3: Command failed.
error /Users/hyunjaelee/work/polymath-core/node_modules/sha3: Command failed.
Exit code: 1
Command: node-gyp rebuild
Arguments:
Directory: /Users/hyunjaelee/work/polymath-core/node_modules/sha3
Output:
gyp info it worked if it ends with ok
gyp info using node-gyp@10.0.1
gyp info using node@21.2.0 | darwin | x64
gyp info find Python using Python version 3.9.6 found at "/Library/Developer/CommandLineTools/usr/bin/python3"
gyp http GET https://nodejs.org/download/release/v21.2.0/node-v21.2.0-headers.tar.gz
gyp http 200 https://nodejs.org/download/release/v21.2.0/node-v21.2.0-headers.tar.gz
gyp http GET https://nodejs.org/download/release/v21.2.0/SHASUMS256.txt
gyp http 200 https://nodejs.org/download/release/v21.2.0/SHASUMS256.txt
gyp info spawn /Library/Developer/CommandLineTools/usr/bin/python3
gyp info spawn args [
gyp info spawn args '/usr/local/Cellar/node/21.2.0/libexec/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args 'binding.gyp',
gyp info spawn args '-f',
gyp info spawn args 'make',
gyp info spawn args '-I',
gyp info spawn args '/Users/hyunjaelee/work/polymath-core/node_modules/sha3/build/config.gypi',
gyp info spawn args '-I',
gyp info spawn args '/usr/local/Cellar/node/21.2.0/libexec/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
gyp info spawn args '-I',
gyp info spawn args '/Users/hyunjaelee/Library/Caches/node-gyp/21.2.0/include/node/common.gypi',
gyp info spawn args '-Dlibrary=shared_library',
gyp info spawn args '-Dvisibility=default',
gyp info spawn args '-Dnode_root_dir=/Users/hyunjaelee/Library/Caches/node-gyp/21.2.0',
gyp info spawn args '-Dnode_gyp_dir=/usr/local/Cellar/node/21.2.0/libexec/lib/node_modules/npm/node_modules/node-gyp',
gyp info spawn args '-Dnode_lib_file=/Users/hyunjaelee/Library/Caches/node-gyp/21.2.0/<(target_arch)/node.lib',
gyp info spawn args '-Dmodule_root_dir=/Users/hyunjaelee/work/polymath-core/node_modules/sha3',
gyp info spawn args '-Dnode_engine=v8',
gyp info spawn args '--depth=.',
gyp info spawn args '--no-parallel',
gyp info spawn args '--generator-output',
gyp info spawn args 'build',
gyp info spawn args '-Goutput_dir=.'
gyp info spawn args ]
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
CXX(target) Release/obj.target/sha3/src/addon.o
In file included from ../src/addon.cpp:4:
In file included from ../node_modules/nan/nan.h:173:
../node_modules/nan/nan_callbacks.h:55:23: error: no member named 'AccessorSignature' in namespace 'v8'
typedef v8::Local<v8::AccessorSignature> Sig;
~~~~^
In file included from ../src/addon.cpp:4:
../node_modules/nan/nan.h:615:39: warning: 'IdleNotificationDeadline' is deprecated: Use MemoryPressureNotification() to influence the GC schedule. [-Wdeprecated-declarations]
return v8::Isolate::GetCurrent()->IdleNotificationDeadline(
^
/Users/hyunjaelee/Library/Caches/node-gyp/21.2.0/include/node/v8-isolate.h:1339:3: note: 'IdleNotificationDeadline' has been explicitly marked deprecated here
V8_DEPRECATE_SOON(
^
/Users/hyunjaelee/Library/Caches/node-gyp/21.2.0/include/node/v8config.h:551:39: note: expanded from macro 'V8_DEPRECATE_SOON'
# define V8_DEPRECATE_SOON(message) [[deprecated(message)]]
^
In file included from ../src/addon.cpp:4:
../node_modules/nan/nan.h:2470:8: error: no matching member function for call to 'SetAccessor'
tpl->SetAccessor(
~~~~~^~~~~~~~~~~
/Users/hyunjaelee/Library/Caches/node-gyp/21.2.0/include/node/v8-template.h:816:8: note: candidate function not viable: no known conversion from 'imp::Sig' (aka 'int') to 'SideEffectType' for 7th argument
void SetAccessor(
^
/Users/hyunjaelee/Library/Caches/node-gyp/21.2.0/include/node/v8-template.h:809:8: note: candidate function not viable: no known conversion from 'imp::NativeGetter' (aka 'void (*)(v8::Local<v8::Name>, const v8::PropertyCallbackInfo<v8::Value> &)') to 'AccessorGetterCallback' (aka 'void (*)(Local<String>, const PropertyCallbackInfo<Value> &)') for 2nd argument
void SetAccessor(
^
In file included from ../src/addon.cpp:4:
In file included from ../node_modules/nan/nan.h:2818:
../node_modules/nan/nan_typedarray_contents.h:34:43: error: no member named 'GetContents' in 'v8::ArrayBuffer'
data = static_cast<char*>(buffer->GetContents().Data()) + byte_offset;
~~~~~~~~^
In file included from ../src/addon.cpp:9:
In file included from ../src/KeccakNISTInterface.h:17:
../src/KeccakSponge.h:23:9: warning: 'ALIGN' macro redefined [-Wmacro-redefined]
#define ALIGN __attribute__ ((aligned(32)))
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/i386/param.h:85:9: note: previous definition is here
#define ALIGN(p) __DARWIN_ALIGN(p)
^
In file included from ../src/addon.cpp:1:
In file included from /Users/hyunjaelee/Library/Caches/node-gyp/21.2.0/include/node/node.h:73:
In file included from /Users/hyunjaelee/Library/Caches/node-gyp/21.2.0/include/node/v8.h:24:
In file included from /Users/hyunjaelee/Library/Caches/node-gyp/21.2.0/include/node/v8-array-buffer.h:12:
/Users/hyunjaelee/Library/Caches/node-gyp/21.2.0/include/node/v8-local-handle.h:253:5: error: static assertion failed due to requirement 'std::is_base_of<v8::Value, v8::Data>::value': type check
static_assert(std::is_base_of<T, S>::value, "type check");
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../node_modules/nan/nan_callbacks_12_inl.h:175:20: note: in instantiation of function template specialization 'v8::Local<v8::Value>::Local<v8::Data>' requested here
cbinfo(info, obj->GetInternalField(kDataIndex));
^
2 warnings and 4 errors generated.
make: *** [Release/obj.target/sha3/src/addon.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.<anonymous> (/usr/local/Cellar/node/21.2.0/libexec/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:209:23)
gyp ERR! System Darwin 23.0.0
gyp ERR! command "/usr/local/Cellar/node/21.2.0/bin/node" "/usr/local/Cellar/node/21.2.0/libexec/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/hyunjaelee/work/polymath-core/node_modules/sha3
๐ ํด๊ฒฐ Node 16 ๋ฒ์ ์ ์ฌ์ฉํจ์ผ๋ก์จ ํด๊ฒฐ
nvm use 16
Solidity
function type ๋ฐ๊พธ๊ธฐ
function _getManifest() internal view returns (PluginManifest memory) {
PluginManifest memory m = abi.decode(_manifest, (PluginManifest));
return m;
}
function _castToPure(
function() internal view returns (PluginManifest memory) fnIn
)
internal
pure
returns (function() internal pure returns (PluginManifest memory) fnOut)
{
assembly ("memory-safe") {
fnOut := fnIn
}
}
function pluginManifest() external pure returns (PluginManifest memory) {
return _castToPure(_getManifest)();
}
getContractFactory & ContractFactory
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
contract Greeter {
string internal _greeting;
constructor(string memory newGreeting) {
_greeting = newGreeting;
}
function setGreeting(string memory newGreeting) public {
_greeting = newGreeting;
}
function greet() public view returns (string memory) {
return _greeting;
}
}
import { ethers } from "hardhat";
import { expect } from "chai";
import Greeter from "../artifacts/contracts/Greeter.sol/Greeter.json";
describe("ContractFactory", function () {
async function greeterFixture() {
const [owner, otherAccount] = await ethers.getSigners();
return { owner, otherAccount };
}
it("Should return the new contract instance", async function () {
const Factory = await ethers.getContractFactory("Greeter");
const greeter = await Factory.deploy("Hello, Hardhat!");
console.log("Greeter deployed to:", greeter.target);
expect(await greeter.greet()).to.equal("Hello, Hardhat!");
});
it("Should create a new contract instance with ethers.ContractFactory", async function () {
const { owner } = await greeterFixture();
const greeter = await new ethers.ContractFactory(
Greeter.abi, Greeter.bytecode, owner).
deploy("Hello, Hardhat!");
const contract = await ethers.getContractAt('Greeter', greeter.target, owner);
expect(await contract.greet()).to.equal("Hello, Hardhat!");
});
});
Smart Contract/Hardhat
๐๐๐ฆโพ๏ธ๐ณ๐๐ผ๐ธ๐๐๐๐ถ๐ฆโ๏ธ๐โป
Hardhat config defaultNetwork
create2 ํจ์
์๋ ํจ์๋ UniswapV2Factory์์ ์ฌ์ฉ๋๋ ์ฝ๋์
bytes memory bytecode = type(UniswapV2Pair).creationCode;
bytes32 salt = keccak256(abi.encodePacked(token0, token1));
assembly {
pair := create2(0, add(bytecode, 32), mload(bytecode), salt)
}
Unlike create, which generates the contract address based on the address of the creator and how many contracts it has created (nonce), create2 generates the address using the creator's address, a provided salt, and the hash of the initialization code. This allows for predictable computation of the contract's address before the contract is actually deployed.
Endowment (0): This is the amount of Ether, in wei, that is sent to the new contract upon creation. In this case, it's set to 0, meaning no Ether is sent.
Memory Start (add(bytecode, 32)): bytecode is the initialization code for the contract you want to create. In Solidity, contract bytecode is often stored in an array, and this array includes a 32-byte length prefix. add(bytecode, 32) calculates the starting point of the actual bytecode, skipping the first 32 bytes which represent the length of the bytecode. This is necessary because create2 requires a pointer to the start of the actual code, not the length prefix. Size of Code (mload(bytecode)):
mload(bytecode) is used to load the first 32 bytes of bytecode, which, as mentioned, contain its size. This tells create2 how much of the memory starting from add(bytecode, 32) it should read and use as the initialization code. Salt (salt):
The salt is a 32-byte value that you provide. It's part of the formula used to calculate the address of the new contract. In your code, salt is generated from the hash of two token addresses, which helps ensure that each pair of tokens gets a unique contract address.
ํธ๋์ญ์ ์ทจ์ํ๋ ๋ฐฉ๋ฒ
- https://support.metamask.io/hc/en-us/articles/360015489251-How-to-speed-up-or-cancel-a-pending-transaction
- MetaMask์ ์ค์ ์ ๊ณ ๊ธ์ ๋ค์ด๊ฐ์ "ํ๋ ๋ฐ ๋ ผ์ค ๋ฐ์ดํฐ ์ง์ฐ๊ธฐ"
Nonce ์ป์ด๋ด๊ธฐ
- docker exec -it pow-node geth attach data/geth.ipc
- eth.getTransactionCount("0x8B595d325485a0Ca9d41908cAbF265E23C172847")
- ์ฌ๊ธฐ์ ๋ํ๋๋ Nonce๋ฅผ ํธ๋์ญ์ ์์ ์ฌ์ฉํ๋ ๊ฒ์.
- ๋ค๋ฅธ ๋ฐฉ๋ฒ
- const nonce = await provider.getTransactionCount(admin.address);
Type error: Cannot find module '../typechain-types' or its corresponding type declarations.
๊ทธ๋ฅ typechain-types ํด๋๋ฅผ ์ฐ์ง ์๊ธฐ๋ก ํจ
Error HH412: Invalid import
Error HH412: Invalid import @poohnet/pooh-swap-v2-core/contracts/interfaces/IUniswapV2Factory.sol from contracts/periphery/UniswapV2Router01.sol. Trying to import file using the own package's name.
- import ๋์์ธ @poohnet/pooh-swap-v2-core๊ณผ package.json์ name์ด ๋์ผํด์ ์๊ธด ๋ฌธ์
- chatGPT์๊ฒ ๋ฌผ์ด์ ํด๊ฒฐ๋จ.
Error: network does not support ENS
๋ค์๊ณผ ๊ฐ์ด VAULT_CONTRACT ์ฃผ์ ์๋ชป๋จ, ์ฆ, 0x๊ฐ ๋๋ฒ ์ฐ์ด๊ณ ์์์. VAULT_CONTRACT=0x0x7f28F281d57AC7d99A8C2FAd2d37271c2c9c67D6
L1-governance ๋ฐฐํฌ ์๋ฌ
L1-governance git:(main) โ yarn hardhat run --network localnet ./scripts/deploy.ts
yarn run v1.22.19
warning package.json: No license field
$ /Users/hyunjaelee/work/tutorials/L1-governance/node_modules/.bin/hardhat run --network localnet ./scripts/deploy.ts
TypeError: (0 , ethers_1.getAddress) is not a function
๐ ๋ค์์ ์ธ๋จ๊ณ ํ์
- yarn add --dev hardhat @nomiclabs/hardhat-ethers@npm:hardhat-deploy-ethers ethers
- const deployed = await contract.waitForDeployment();
- console.log(
Governance contract was successfully deployed at ${await deployed.getAddress()});
๐ ์์ธ
- ethers ๋ฒ์ ์ด 6์ผ๋ก ์ ๊ทธ๋ ์ด๋๋๋ฉด์ ํจ์๋ช ์ด ๋ฐ๋์์
- ๊ธฐํ
- 0xAe9Bc22B80D98aD3350a35118F723d36d8E4e141
wait ํจ์์ ์ธ์
The wait() function of ContractTransaction takes a single optional argument, which is the timeout in blocks. The default timeout is 10 blocks. This means that the wait() function will block for up to 10 blocks before throwing an error if the transaction has not been confirmed. You can increase the timeout period by passing a higher number to the wait() function. For example, the following code will block for up to 20 blocks before throwing an error:
Contract Size
https://ethereum.stackexchange.com/questions/31515/how-to-check-the-size-of-a-contract-in-solidity
Exceeds Gas Limit ์๋ฌ
- Genesis.json์์ gasLimit๋ฅผ ์๋ฌ ๋ด์ฉ์
- ์๋ฌ๋ด์ฉ "gasLimit: BigNumber { _hex: '0x989680', _isBigNumber: true }" ๋งํผ์ผ๋ก ๋๋ ค์ค.
Error: Error: processing response error (body="{\"jsonrpc\":\"2.0\",\"id\":151,\"error\":{\"code\":-32000,\"message\":\"exceeds block gas limit\"}}\n", error={"code":-32000}, requestBody="{\"method\":\"eth_sendRawTransaction\",\"params\":[\"0x02f90fd382300d0284461bffd584461bffd58398968094572b9410d9a14fa729f3af92cb83a07aaa472de080b90f644af63f020000000000000000000000000000000000000000000000000000000000000040fe07c7c6f88cdf003f00c1e47076de3576e136c7114496823271143b3d46e97e0000000000000000000000000000000000000000000000000000000000000ef9608060405234801561001057600080fd5b50610ed9806100206000396000f3fe6080604052600436106100f35760003560e01c80634d2301cc1161008a578063a8b0574e11610059578063a8b0574e1461025a578063bce38bd714610275578063c3077fa914610288578063ee82ac5e1461029b57600080fd5b80634d2301cc146101ec57806372425d9d1461022157806382ad56cb1461023457806386d516e81461024757600080fd5b80633408e470116100c65780633408e47014610191578063399542e9146101a45780633e64a696146101c657806342cbb15c146101d957600080fd5b80630f28c97d146100f8578063174dea711461011a578063252dba421461013a57806327e86d6e1461015b575b600080fd5b34801561010457600080fd5b50425b6040519081526020015b60405180910390f35b61012d610128366004610a85565b6102ba565b6040516101119190610bb7565b61014d610148366004610a85565b6104ef565b604051610111929190610bd1565b34801561016757600080fd5b50437fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0140610107565b34801561019d57600080fd5b5046610107565b6101b76101b2366004610c59565b610690565b60405161011193929190610cb3565b3480156101d257600080fd5b5048610107565b3480156101e557600080fd5b5043610107565b3480156101f857600080fd5b50610107610207366004610cdb565b73ffffffffffffffffffffffffffffffffffffffff163190565b34801561022d57600080fd5b5044610107565b61012d610242366004610a85565b6106ab565b34801561025357600080fd5b5045610107565b34801561026657600080fd5b50604051418152602001610111565b61012d610283366004610c59565b61085a565b6101b7610296366004610a85565b610a1a565b3480156102a757600080fd5b506101076102b6366004610d11565b4090565b60606000828067ffffffffffffffff8111156102d8576102d8610d2a565b60405190808252806020026020018201604052801561031e57816020015b6040805180820190915260008152606060208201528152602001906001900390816102f65790505b5092503660005b8281101561047757600085828151811061034157610341610d59565b6020026020010151905087878381811061035d5761035d610d59565b905060200281019061036f9190610d88565b6040810135958601959093506103886020850185610cdb565b73ffffffffffffffffffffffffffffffffffffffff16816103ac6060870187610dc6565b6040516103ba929190610e2b565b60006040518083038185875af1925050503d80600081146103f7576040519150601f19603f3d011682016040523d82523d6000602084013e6103fc565b606091505b50602080850191909152901515808452908501351761046d577f08c379a000000000000000000000000000000000000000000000000000000000600052602060045260176024527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060445260846000fd5b5050600101610325565b508234146104e6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f4d756c746963616c6c333a2076616c7565206d69736d6174636800000000000060448201526064015b60405180910390fd5b50505092915050565b436060828067ffffffffffffffff81111561050c5761050c610d2a565b60405190808252806020026020018201604052801561053f57816020015b606081526020019060019003908161052a5790505b5091503660005b8281101561068657600087878381811061056257610562610d59565b90506020028101906105749190610e3b565b92506105836020840184610cdb565b73ffffffffffffffffffffffffffffffffffffffff166105a66020850185610dc6565b6040516105b4929190610e2b565b6000604051808303816000865af19150503d80600081146105f1576040519150601f19603f3d011682016040523d82523d6000602084013e6105f6565b606091505b5086848151811061060957610609610d59565b602090810291909101015290508061067d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060448201526064016104dd565b50600101610546565b5050509250929050565b43804060606106a086868661085a565b905093509350939050565b6060818067ffffffffffffffff8111156106c7576106c7610d2a565b60405190808252806020026020018201604052801561070d57816020015b6040805180820190915260008152606060208201528152602001906001900390816106e55790505b5091503660005b828110156104e657600084828151811061073057610730610d59565b6020026020010151905086868381811061074c5761074c610d59565b905060200281019061075e9190610e6f565b925061076d6020840184610cdb565b73ffffffffffffffffffffffffffffffffffffffff166107906040850185610dc6565b60405161079e929190610e2b565b6000604051808303816000865af19150503d80600081146107db576040519150601f19603f3d011682016040523d82523d6000602084013e6107e0565b606091505b506020808401919091529015158083529084013517610851577f08c379a000000000000000000000000000000000000000000000000000000000600052602060045260176024527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060445260646000fd5b50600101610714565b6060818067ffffffffffffffff81111561087657610876610d2a565b6040519080825280602002602001820160405280156108bc57816020015b6040805180820190915260008152606060208201528152602001906001900390816108945790505b5091503660005b82811015610a105760008482815181106108df576108df610d59565b602002602001015190508686838181106108fb576108fb610d59565b905060200281019061090d9190610e3b565b925061091c6020840184610cdb565b73ffffffffffffffffffffffffffffffffffffffff1661093f6020850185610dc6565b60405161094d929190610e2b565b6000604051808303816000865af19150503d806000811461098a576040519150601f19603f3d011682016040523d82523d6000602084013e61098f565b606091505b506020830152151581528715610a07578051610a07576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060448201526064016104dd565b506001016108c3565b5050509392505050565b6000806060610a2b60018686610690565b919790965090945092505050565b60008083601f840112610a4b57600080fd5b50813567ffffffffffffffff811115610a6357600080fd5b6020830191508360208260051b8501011115610a7e57600080fd5b9250929050565b60008060208385031215610a9857600080fd5b823567ffffffffffffffff811115610aaf57600080fd5b610abb85828601610a39565b90969095509350505050565b6000815180845260005b81811015610aed57602081850181015186830182015201610ad1565b5060006020828601015260207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f83011685010191505092915050565b600082825180855260208086019550808260051b84010181860160005b84811015610baa578583037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe001895281518051151584528401516040858501819052610b9681860183610ac7565b9a86019a9450505090830190600101610b48565b5090979650505050505050565b602081526000610bca6020830184610b2b565b9392505050565b600060408201848352602060408185015281855180845260608601915060608160051b870101935082870160005b82811015610c4b577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa0888703018452610c39868351610ac7565b95509284019290840190600101610bff565b509398975050505050505050565b600080600060408486031215610c6e57600080fd5b83358015158114610c7e57600080fd5b9250602084013567ffffffffffffffff811115610c9a57600080fd5b610ca686828701610a39565b9497909650939450505050565b838152826020820152606060408201526000610cd26060830184610b2b565b95945050505050565b600060208284031215610ced57600080fd5b813573ffffffffffffffffffffffffffffffffffffffff81168114610bca57600080fd5b600060208284031215610d2357600080fd5b5035919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600082357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81833603018112610dbc57600080fd5b9190910192915050565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe1843603018112610dfb57600080fd5b83018035915067ffffffffffffffff821115610e1657600080fd5b602001915036819003821315610a7e57600080fd5b8183823760009101908152919050565b600082357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc1833603018112610dbc57600080fd5b600082357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa1833603018112610dbc57600080fdfea2646970667358221220eca0cb14f4322010c8eb410ba0738474f94c966328e9db21a580ada159aa6c8564736f6c6343000811003300000000000000c080a086a949d9a5e6c0fca3315b4363c12e9a3953b20445bf0fbe3f659212e7792c92a02e2e4680f844eab38c40aa61874bc199fc45d96ac3d91fe668039df54e060786\"],\"id\":151,\"jsonrpc\":\"2.0\"}", requestMethod="POST", url="http://localhost:8545", code=SERVER_ERROR, version=web/5.7.1)
at Logger.makeError (/Users/hyunjaelee/work/zksync-era/node_modules/@ethersproject/logger/src.ts/index.ts:269:28)
at Logger.throwError (/Users/hyunjaelee/work/zksync-era/node_modules/@ethersproject/logger/src.ts/index.ts:281:20)
at /Users/hyunjaelee/work/zksync-era/node_modules/@ethersproject/web/src.ts/index.ts:341:28
at step (/Users/hyunjaelee/work/zksync-era/node_modules/@ethersproject/web/lib/index.js:33:23)
at Object.next (/Users/hyunjaelee/work/zksync-era/node_modules/@ethersproject/web/lib/index.js:14:53)
at fulfilled (/Users/hyunjaelee/work/zksync-era/node_modules/@ethersproject/web/lib/index.js:5:58)
at processTicksAndRejections (node:internal/process/task_queues:96:5) {
reason: 'processing response error',
code: 'SERVER_ERROR',
body: '{"jsonrpc":"2.0","id":151,"error":{"code":-32000,"message":"exceeds block gas limit"}}\n',
error: Error: exceeds block gas limit
at getResult (/Users/hyunjaelee/work/zksync-era/node_modules/@ethersproject/providers/src.ts/json-rpc-provider.ts:142:28)
at processJsonFunc (/Users/hyunjaelee/work/zksync-era/node_modules/@ethersproject/web/src.ts/index.ts:383:22)
at /Users/hyunjaelee/work/zksync-era/node_modules/@ethersproject/web/src.ts/index.ts:320:42
at step (/Users/hyunjaelee/work/zksync-era/node_modules/@ethersproject/web/lib/index.js:33:23)
at Object.next (/Users/hyunjaelee/work/zksync-era/node_modules/@ethersproject/web/lib/index.js:14:53)
at fulfilled (/Users/hyunjaelee/work/zksync-era/node_modules/@ethersproject/web/lib/index.js:5:58)
at processTicksAndRejections (node:internal/process/task_queues:96:5) {
code: -32000,
data: undefined
},
requestBody: '{"method":"eth_sendRawTransaction","params":["0x02f90fd382300d0284461bffd584461bffd58398968094572b9410d9a14fa729f3af92cb83a07aaa472de080b90f644af63f020000000000000000000000000000000000000000000000000000000000000040fe07c7c6f88cdf003f00c1e47076de3576e136c7114496823271143b3d46e97e0000000000000000000000000000000000000000000000000000000000000ef9608060405234801561001057600080fd5b50610ed9806100206000396000f3fe6080604052600436106100f35760003560e01c80634d2301cc1161008a578063a8b0574e11610059578063a8b0574e1461025a578063bce38bd714610275578063c3077fa914610288578063ee82ac5e1461029b57600080fd5b80634d2301cc146101ec57806372425d9d1461022157806382ad56cb1461023457806386d516e81461024757600080fd5b80633408e470116100c65780633408e47014610191578063399542e9146101a45780633e64a696146101c657806342cbb15c146101d957600080fd5b80630f28c97d146100f8578063174dea711461011a578063252dba421461013a57806327e86d6e1461015b575b600080fd5b34801561010457600080fd5b50425b6040519081526020015b60405180910390f35b61012d610128366004610a85565b6102ba565b6040516101119190610bb7565b61014d610148366004610a85565b6104ef565b604051610111929190610bd1565b34801561016757600080fd5b50437fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0140610107565b34801561019d57600080fd5b5046610107565b6101b76101b2366004610c59565b610690565b60405161011193929190610cb3565b3480156101d257600080fd5b5048610107565b3480156101e557600080fd5b5043610107565b3480156101f857600080fd5b50610107610207366004610cdb565b73ffffffffffffffffffffffffffffffffffffffff163190565b34801561022d57600080fd5b5044610107565b61012d610242366004610a85565b6106ab565b34801561025357600080fd5b5045610107565b34801561026657600080fd5b50604051418152602001610111565b61012d610283366004610c59565b61085a565b6101b7610296366004610a85565b610a1a565b3480156102a757600080fd5b506101076102b6366004610d11565b4090565b60606000828067ffffffffffffffff8111156102d8576102d8610d2a565b60405190808252806020026020018201604052801561031e57816020015b6040805180820190915260008152606060208201528152602001906001900390816102f65790505b5092503660005b8281101561047757600085828151811061034157610341610d59565b6020026020010151905087878381811061035d5761035d610d59565b905060200281019061036f9190610d88565b6040810135958601959093506103886020850185610cdb565b73ffffffffffffffffffffffffffffffffffffffff16816103ac6060870187610dc6565b6040516103ba929190610e2b565b60006040518083038185875af1925050503d80600081146103f7576040519150601f19603f3d011682016040523d82523d6000602084013e6103fc565b606091505b50602080850191909152901515808452908501351761046d577f08c379a000000000000000000000000000000000000000000000000000000000600052602060045260176024527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060445260846000fd5b5050600101610325565b508234146104e6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f4d756c746963616c6c333a2076616c7565206d69736d6174636800000000000060448201526064015b60405180910390fd5b50505092915050565b436060828067ffffffffffffffff81111561050c5761050c610d2a565b60405190808252806020026020018201604052801561053f57816020015b606081526020019060019003908161052a5790505b5091503660005b8281101561068657600087878381811061056257610562610d59565b90506020028101906105749190610e3b565b92506105836020840184610cdb565b73ffffffffffffffffffffffffffffffffffffffff166105a66020850185610dc6565b6040516105b4929190610e2b565b6000604051808303816000865af19150503d80600081146105f1576040519150601f19603f3d011682016040523d82523d6000602084013e6105f6565b606091505b5086848151811061060957610609610d59565b602090810291909101015290508061067d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060448201526064016104dd565b50600101610546565b5050509250929050565b43804060606106a086868661085a565b905093509350939050565b6060818067ffffffffffffffff8111156106c7576106c7610d2a565b60405190808252806020026020018201604052801561070d57816020015b6040805180820190915260008152606060208201528152602001906001900390816106e55790505b5091503660005b828110156104e657600084828151811061073057610730610d59565b6020026020010151905086868381811061074c5761074c610d59565b905060200281019061075e9190610e6f565b925061076d6020840184610cdb565b73ffffffffffffffffffffffffffffffffffffffff166107906040850185610dc6565b60405161079e929190610e2b565b6000604051808303816000865af19150503d80600081146107db576040519150601f19603f3d011682016040523d82523d6000602084013e6107e0565b606091505b506020808401919091529015158083529084013517610851577f08c379a000000000000000000000000000000000000000000000000000000000600052602060045260176024527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060445260646000fd5b50600101610714565b6060818067ffffffffffffffff81111561087657610876610d2a565b6040519080825280602002602001820160405280156108bc57816020015b6040805180820190915260008152606060208201528152602001906001900390816108945790505b5091503660005b82811015610a105760008482815181106108df576108df610d59565b602002602001015190508686838181106108fb576108fb610d59565b905060200281019061090d9190610e3b565b925061091c6020840184610cdb565b73ffffffffffffffffffffffffffffffffffffffff1661093f6020850185610dc6565b60405161094d929190610e2b565b6000604051808303816000865af19150503d806000811461098a576040519150601f19603f3d011682016040523d82523d6000602084013e61098f565b606091505b506020830152151581528715610a07578051610a07576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060448201526064016104dd565b506001016108c3565b5050509392505050565b6000806060610a2b60018686610690565b919790965090945092505050565b60008083601f840112610a4b57600080fd5b50813567ffffffffffffffff811115610a6357600080fd5b6020830191508360208260051b8501011115610a7e57600080fd5b9250929050565b60008060208385031215610a9857600080fd5b823567ffffffffffffffff811115610aaf57600080fd5b610abb85828601610a39565b90969095509350505050565b6000815180845260005b81811015610aed57602081850181015186830182015201610ad1565b5060006020828601015260207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f83011685010191505092915050565b600082825180855260208086019550808260051b84010181860160005b84811015610baa578583037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe001895281518051151584528401516040858501819052610b9681860183610ac7565b9a86019a9450505090830190600101610b48565b5090979650505050505050565b602081526000610bca6020830184610b2b565b9392505050565b600060408201848352602060408185015281855180845260608601915060608160051b870101935082870160005b82811015610c4b577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa0888703018452610c39868351610ac7565b95509284019290840190600101610bff565b509398975050505050505050565b600080600060408486031215610c6e57600080fd5b83358015158114610c7e57600080fd5b9250602084013567ffffffffffffffff811115610c9a57600080fd5b610ca686828701610a39565b9497909650939450505050565b838152826020820152606060408201526000610cd26060830184610b2b565b95945050505050565b600060208284031215610ced57600080fd5b813573ffffffffffffffffffffffffffffffffffffffff81168114610bca57600080fd5b600060208284031215610d2357600080fd5b5035919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600082357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81833603018112610dbc57600080fd5b9190910192915050565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe1843603018112610dfb57600080fd5b83018035915067ffffffffffffffff821115610e1657600080fd5b602001915036819003821315610a7e57600080fd5b8183823760009101908152919050565b600082357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc1833603018112610dbc57600080fd5b600082357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa1833603018112610dbc57600080fdfea2646970667358221220eca0cb14f4322010c8eb410ba0738474f94c966328e9db21a580ada159aa6c8564736f6c6343000811003300000000000000c080a086a949d9a5e6c0fca3315b4363c12e9a3953b20445bf0fbe3f659212e7792c92a02e2e4680f844eab38c40aa61874bc199fc45d96ac3d91fe668039df54e060786"],"id":151,"jsonrpc":"2.0"}',
requestMethod: 'POST',
url: 'http://localhost:8545',
transaction: {
type: 2,
chainId: 12301,
nonce: 2,
maxPriorityFeePerGas: BigNumber { _hex: '0x461bffd5', _isBigNumber: true },
maxFeePerGas: BigNumber { _hex: '0x461bffd5', _isBigNumber: true },
gasPrice: null,
gasLimit: BigNumber { _hex: '0x989680', _isBigNumber: true },
to: '0x572b9410D9a14Fa729F3af92cB83A07aaA472dE0',
value: BigNumber { _hex: '0x00', _isBigNumber: true },
data: '0x4af63f020000000000000000000000000000000000000000000000000000000000000040fe07c7c6f88cdf003f00c1e47076de3576e136c7114496823271143b3d46e97e0000000000000000000000000000000000000000000000000000000000000ef9608060405234801561001057600080fd5b50610ed9806100206000396000f3fe6080604052600436106100f35760003560e01c80634d2301cc1161008a578063a8b0574e11610059578063a8b0574e1461025a578063bce38bd714610275578063c3077fa914610288578063ee82ac5e1461029b57600080fd5b80634d2301cc146101ec57806372425d9d1461022157806382ad56cb1461023457806386d516e81461024757600080fd5b80633408e470116100c65780633408e47014610191578063399542e9146101a45780633e64a696146101c657806342cbb15c146101d957600080fd5b80630f28c97d146100f8578063174dea711461011a578063252dba421461013a57806327e86d6e1461015b575b600080fd5b34801561010457600080fd5b50425b6040519081526020015b60405180910390f35b61012d610128366004610a85565b6102ba565b6040516101119190610bb7565b61014d610148366004610a85565b6104ef565b604051610111929190610bd1565b34801561016757600080fd5b50437fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0140610107565b34801561019d57600080fd5b5046610107565b6101b76101b2366004610c59565b610690565b60405161011193929190610cb3565b3480156101d257600080fd5b5048610107565b3480156101e557600080fd5b5043610107565b3480156101f857600080fd5b50610107610207366004610cdb565b73ffffffffffffffffffffffffffffffffffffffff163190565b34801561022d57600080fd5b5044610107565b61012d610242366004610a85565b6106ab565b34801561025357600080fd5b5045610107565b34801561026657600080fd5b50604051418152602001610111565b61012d610283366004610c59565b61085a565b6101b7610296366004610a85565b610a1a565b3480156102a757600080fd5b506101076102b6366004610d11565b4090565b60606000828067ffffffffffffffff8111156102d8576102d8610d2a565b60405190808252806020026020018201604052801561031e57816020015b6040805180820190915260008152606060208201528152602001906001900390816102f65790505b5092503660005b8281101561047757600085828151811061034157610341610d59565b6020026020010151905087878381811061035d5761035d610d59565b905060200281019061036f9190610d88565b6040810135958601959093506103886020850185610cdb565b73ffffffffffffffffffffffffffffffffffffffff16816103ac6060870187610dc6565b6040516103ba929190610e2b565b60006040518083038185875af1925050503d80600081146103f7576040519150601f19603f3d011682016040523d82523d6000602084013e6103fc565b606091505b50602080850191909152901515808452908501351761046d577f08c379a000000000000000000000000000000000000000000000000000000000600052602060045260176024527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060445260846000fd5b5050600101610325565b508234146104e6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f4d756c746963616c6c333a2076616c7565206d69736d6174636800000000000060448201526064015b60405180910390fd5b50505092915050565b436060828067ffffffffffffffff81111561050c5761050c610d2a565b60405190808252806020026020018201604052801561053f57816020015b606081526020019060019003908161052a5790505b5091503660005b8281101561068657600087878381811061056257610562610d59565b90506020028101906105749190610e3b565b92506105836020840184610cdb565b73ffffffffffffffffffffffffffffffffffffffff166105a66020850185610dc6565b6040516105b4929190610e2b565b6000604051808303816000865af19150503d80600081146105f1576040519150601f19603f3d011682016040523d82523d6000602084013e6105f6565b606091505b5086848151811061060957610609610d59565b602090810291909101015290508061067d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060448201526064016104dd565b50600101610546565b5050509250929050565b43804060606106a086868661085a565b905093509350939050565b6060818067ffffffffffffffff8111156106c7576106c7610d2a565b60405190808252806020026020018201604052801561070d57816020015b6040805180820190915260008152606060208201528152602001906001900390816106e55790505b5091503660005b828110156104e657600084828151811061073057610730610d59565b6020026020010151905086868381811061074c5761074c610d59565b905060200281019061075e9190610e6f565b925061076d6020840184610cdb565b73ffffffffffffffffffffffffffffffffffffffff166107906040850185610dc6565b60405161079e929190610e2b565b6000604051808303816000865af19150503d80600081146107db576040519150601f19603f3d011682016040523d82523d6000602084013e6107e0565b606091505b506020808401919091529015158083529084013517610851577f08c379a000000000000000000000000000000000000000000000000000000000600052602060045260176024527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060445260646000fd5b50600101610714565b6060818067ffffffffffffffff81111561087657610876610d2a565b6040519080825280602002602001820160405280156108bc57816020015b6040805180820190915260008152606060208201528152602001906001900390816108945790505b5091503660005b82811015610a105760008482815181106108df576108df610d59565b602002602001015190508686838181106108fb576108fb610d59565b905060200281019061090d9190610e3b565b925061091c6020840184610cdb565b73ffffffffffffffffffffffffffffffffffffffff1661093f6020850185610dc6565b60405161094d929190610e2b565b6000604051808303816000865af19150503d806000811461098a576040519150601f19603f3d011682016040523d82523d6000602084013e61098f565b606091505b506020830152151581528715610a07578051610a07576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060448201526064016104dd565b506001016108c3565b5050509392505050565b6000806060610a2b60018686610690565b919790965090945092505050565b60008083601f840112610a4b57600080fd5b50813567ffffffffffffffff811115610a6357600080fd5b6020830191508360208260051b8501011115610a7e57600080fd5b9250929050565b60008060208385031215610a9857600080fd5b823567ffffffffffffffff811115610aaf57600080fd5b610abb85828601610a39565b90969095509350505050565b6000815180845260005b81811015610aed57602081850181015186830182015201610ad1565b5060006020828601015260207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f83011685010191505092915050565b600082825180855260208086019550808260051b84010181860160005b84811015610baa578583037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe001895281518051151584528401516040858501819052610b9681860183610ac7565b9a86019a9450505090830190600101610b48565b5090979650505050505050565b602081526000610bca6020830184610b2b565b9392505050565b600060408201848352602060408185015281855180845260608601915060608160051b870101935082870160005b82811015610c4b577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa0888703018452610c39868351610ac7565b95509284019290840190600101610bff565b509398975050505050505050565b600080600060408486031215610c6e57600080fd5b83358015158114610c7e57600080fd5b9250602084013567ffffffffffffffff811115610c9a57600080fd5b610ca686828701610a39565b9497909650939450505050565b838152826020820152606060408201526000610cd26060830184610b2b565b95945050505050565b600060208284031215610ced57600080fd5b813573ffffffffffffffffffffffffffffffffffffffff81168114610bca57600080fd5b600060208284031215610d2357600080fd5b5035919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600082357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81833603018112610dbc57600080fd5b9190910192915050565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe1843603018112610dfb57600080fd5b83018035915067ffffffffffffffff821115610e1657600080fd5b602001915036819003821315610a7e57600080fd5b8183823760009101908152919050565b600082357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc1833603018112610dbc57600080fd5b600082357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa1833603018112610dbc57600080fdfea2646970667358221220eca0cb14f4322010c8eb410ba0738474f94c966328e9db21a580ada159aa6c8564736f6c6343000811003300000000000000',
accessList: [],
hash: '0x7893259b825674bcb88e9fe491b4390d5f70b8a807cdc57169470db07f431c6c',
v: 0,
r: '0x86a949d9a5e6c0fca3315b4363c12e9a3953b20445bf0fbe3f659212e7792c92',
s: '0x2e2e4680f844eab38c40aa61874bc199fc45d96ac3d91fe668039df54e060786',
from: '0x52312AD6f01657413b2eaE9287f6B9ADaD93D5FE',
confirmations: 0
},
transactionHash: '0x7893259b825674bcb88e9fe491b4390d5f70b8a807cdc57169470db07f431c6c'
}
error Command failed with exit code 1.
hardhat-gas-reporter
hardhat.config.ts ์ฐธ๊ณ : https://github.com/poohgithub/zksync-era/blob/main/poohnet/paymaster-examples/contracts/hardhat.config.ts
Git
๐๐๐ฆโพ๏ธ๐ณ๐๐ผ๐ธ๐๐๐๐ถ๐ฆโ๏ธ๐โป
error: cannot run delta: No such file or directory
๐ ํด๊ฒฐ
brew install git-delta
sudo apt install git-extras
์ด๋ ๊ฒ ํด๋ git diff๋ ์๋๊ธฐ ๋๋ฌธ์ git-delta ๋ช ๋ น๋ง ์ฌ์ฉํ๊ธฐ
fatal: Not possible to fast-forward, aborting.
๐ ํด๊ฒฐ
git fetch origin
git rebase origin/main
Dev Errors
๐๐๐ฆโพ๏ธ๐ณ๐๐ผ๐ธ๐๐๐๐ถ๐ฆโ๏ธ๐โป
failed to compute cache key: "/target/debug/zksync_server" not found: not found
Error: Child process exited with code 1
๐ ํด๊ฒฐ
- .dockerignore์์ ํฌํจ๋์ด ์๋ ๊ฒ์ ์๋์ง ํ์ธ ํ์
- ๋ง์ฝ ๋ก์ปฌ ์์คํ ์์ ๋ณต์ฌ๋๋ ๊ฒ์ด๋ผ๋ฉด ์๋ ์๋ ๊ฒ์ผ ์๋ ์์. ์๋ฅผ ๋ค์ด ์ปดํ์ผ์ ํด์ผ ๋์ค๋ ํ์ผ์ด๋๊ฐ ํ๋ฉด ๊ทธ๋ฐ์ผ์ด ๋ฐ์
Errors
1. Error: VM Exception while processing transaction: reverted with panic code 0x11 (Arithmetic operation underflowed or overflowed outside of an unchecked block)
- ์ฐ์ฐ์ด ์์๊ฐ ๋ ๋, ์ฐฌ๋ฐํ ๊ณ์ฐ์ ๋ฐ์
2. Error: cannot estimate gas; transaction may fail or may require manual gas limit (error="Error: VM Exception while processing transaction: reverted with reason string 'E004'"
Error: cannot estimate gas; transaction may fail or may require manual gas limit (error="Error: VM Exception while processing transaction: reverted with reason string 'E004'", tx={"data":"0x1e28886e3a38e54d9c9b01a63cae0476c624f670359871e7b1463a777cba3247240e31fd76129d005b6f526cbaaf1e1e37494d8091c109bfcf47881a612190af683c1e27000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000412dcb94cce59dd93b63aae7cedc6f7f0b64083b6a29b6f8ce403b2b8f862d8a5a17a797b880310346766ca58d2b9a01b4060b3bfcd7ad02c9aec7da9cd41f77431b00000000000000000000000000000000000000000000000000000000000000","to":{},"from":"0x0e1eE98EDF5BDbc5caaFed491526A0Cd3eD31fad","type":2,"maxFeePerGas":{"type":"BigNumber","hex":"0xa650c80c"},"maxPriorityFeePerGas":{"type":"BigNumber","hex":"0x9502f900"},"nonce":{},"gasLimit":{},"chainId":{}}, code=UNPREDICTABLE_GAS_LIMIT, version=abstract-signer/5.5.0)
3. Error: cannot estimate gas; transaction may fail or may require manual gas limit
Error: cannot estimate gas; transaction may fail or may require manual gas limit [ See: https://links.ethers.org/v5-errors-UNPREDICTABLE_GAS_LIMIT ] (error={"reason":"VM Exception while processing transaction: reverted with reason string 'E000'","code":"UNPREDICTABLE_GAS_LIMIT","method":"estimateGas","transaction":{"from":"0x3287f4b4953471234DbeAFf7d2F9EA58dFedD7fd","maxPriorityFeePerGas":{"type":"BigNumber","hex":"0x59682f00"},"maxFeePerGas":{"type":"BigNumber","hex":"0xa80d7dfe"},"to":"0xeEdC2Ac65dF232AB6d229EBD4E3F564e194ffe7D","value":{"type":"BigNumber","hex":"0x056bc75e2d63100000"},
- ์ด์ฝ๋์์ ๋ฐ์ "IVoteraVote(voteAddress).init("
- ์ด ํจ์๋ฅผ CommonsBudget์์ ํธ์ถ๋์ด์ผํ๋๋ฐ, CommonsStorage์์ ํธ์ถ๋์ด์ initVote์์ ๋ฌธ์ ๊ฐ ๋ฐ์.
4. AssertionError: Expected transaction to be reverted with E001, but other exception was thrown: RangeError: Maximum call stack size exceeded
a. typechain ๋ชจ๋ ์
๊ทธ๋ ์ด๋
b. ์ด ์ปค๋ฐ ์ฐธ์กฐ
5. TypeError: Cannot read property 'eth' of undefined [closed]
โ ์ด ์ฝ๋ ์คํ์ ๋ฐ์
ยง hre.web3.eth.accounts.decrypt(data,"boa2022!@");
โ ๋ค์ ์ค์น ํ์
ยง npm install -s web3
ยง npm install -s @nomiclabs/hardhat-web3
โ hardhat.config.ts์์ ๋ค์ ์ถ๊ฐ
ยง import"@nomiclabs/hardhat-web3";
โ ๊ฒฐ๊ตญ hardhat๊ณผ web3๋ฅผ ์ฐ๊ฒฐํ๋ ์์
์ด ํ์ํจ.
6. HardhatError: HH103: Account 0x3e29aefa7af16625691a9fca4a7fff0624aabc6f is not managed by the node you are connected to.
hardhat.config.ts์ getAccountsํจ์์ ํด๋น ๊ณ์ข๋ฅผ ์ถ๊ฐํด์ผํจ.
ยง accounts:[process.env.ADMIN_KEY||"",process.env.VOTE_KEY||"",process.env.USER_KEY||"",process.env.MANAGER_KEY||""],
7. docker: Got permission denied while trying to connect to the Docker daemon socket
- ์ด๊ฑด screen์ ๋ค์ด๊ฐ์ ์คํํด์ค์ผ ํจ.
1.Create the docker group if it does not exist
$ sudo groupadd docker
2.Add your user to the docker group.
$ sudo usermod -aG docker $USER
3.Run the following command or Logout and login again and run (that doesn't work you may need to reboot your machine first)
$ newgrp docker
8. Authority๋ ธ๋๋ฅผ ์คํ์ํฌ๋, block number๊ฐ ๋์ด๋์ง ์์๋
- run_node๋ฅผ ํตํด์ ์คํ์ํค๋ฉด ๋ค์๊ณผ ๊ฐ์ ๋ด๋ถ IP์ ๋ํ ๋ก๊ทธ๊ฐ ๋์๋ ๋ฌธ์ ๋ ์๋.
self=enode://6d59a1ce195d9251e8f5234b3dbd486cf15eeac6cb8199898af3e11b9b7f5c54e334317d1cc3ab8077360383bc08b8aa93299ccb169b55dbea59414847dbce2d@127.0.0.1:30303
- run_node ์คํฌ๋ฆฝํธ์ bootnode ํญ๋ชฉ์ ๋ค์ด๊ฐ๋ enode์ IP๊ฐ์ด ๋ง์์ผ ํจ.
- static_node.json์ enode ์ ๋ณด๋ฅผ ์ ํํ ์จ์ค์ผ ํจ.
- Node1์ ์ธ๋ถ IP๋ฅผ ํ ๋นํ์๋ ์ฌ๋ถํ ํ์ํจ.
- ์ฑํฌํ๋๋ฐ ์๊ฐ์ด ์ข ๊ฑธ๋ฆผ.
9. Merge pull request #1 from linked0/initial-code
ยฎ ๋๋ฒ์งธ ์ปค๋ฐ์ <Hyunjae Lee>์ด๊ณ , ์ธ๋ฒ์งธ ์ปค๋ฐ์ <Jay>๋ก ๋์ด ์์.
10. ์ด๋ฏธ ์ํฌํธ๋ ๊ณ์ ์ด ์๋๋ฐ ๋ค์ ์ํฌํธ๋ฅผ ํ๋ ค๊ณ ํ ๋ ์๋ฌ๊ฐ ๋จ๋๋ฐ ๊ด๋ จ ์ค๋ช
Imported Accounts are accounts you import using a private key string or a private key JSON file, and were not created with the same Secret Recovery Phrase as your wallet and accounts. For this reason, these accounts will not appear automatically when you restore your MetaMask account with your Secret Recovery Phrase. The data associated with your MetaMask Secret Recovery Phrase cannot be added or extended to the imported account.
11. An unexpected error occurred:
Error: Cannot find module './IERC165__factory' โข ํด๊ฒฐ: typechain-types์ artifacts ํด๋ ์ญ์ โข ์์ธ ๋ด์ฉ
Require stack:
- /Users/hyunjaelee/work/commons-budget-contract/typechain-types/factories/@openzeppelin/contracts/utils/introspection/index.ts
- /Users/hyunjaelee/work/commons-budget-contract/typechain-types/factories/@openzeppelin/contracts/utils/index.ts
- /Users/hyunjaelee/work/commons-budget-contract/typechain-types/factories/@openzeppelin/contracts/index.ts
- /Users/hyunjaelee/work/commons-budget-contract/typechain-types/factories/@openzeppelin/index.ts
- /Users/hyunjaelee/work/commons-budget-contract/typechain-types/factories/index.ts
- /Users/hyunjaelee/work/commons-budget-contract/typechain-types/index.ts
- /Users/hyunjaelee/work/commons-budget-contract/test/VoteHelper.ts
- /Users/hyunjaelee/work/commons-budget-contract/test/AdminAction.test.ts
- /Users/hyunjaelee/work/commons-budget-contract/node_modules/hardhat/node_modules/mocha/lib/mocha.js
- /Users/hyunjaelee/work/commons-budget-contract/node_modules/hardhat/node_modules/mocha/index.js
- /Users/hyunjaelee/work/commons-budget-contract/node_modules/hardhat/builtin-tasks/test.js
- /Users/hyunjaelee/work/commons-budget-contract/node_modules/hardhat/internal/core/tasks/builtin-tasks.js
- /Users/hyunjaelee/work/commons-budget-contract/node_modules/hardhat/internal/core/config/config-loading.js
- /Users/hyunjaelee/work/commons-budget-contract/node_modules/hardhat/internal/cli/cli.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._resolveFilename.sharedData.moduleResolveFilenameHook.installedValue [as _resolveFilename] (/Users/hyunjaelee/work/commons-budget-contract/node_modules/@cspotcode/source-map-support/source-map-support.js:679:30)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (/Users/hyunjaelee/work/commons-budget-contract/typechain-types/factories/@openzeppelin/contracts/utils/introspection/index.ts:4:1)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
at Module.m._compile (/Users/hyunjaelee/work/commons-budget-contract/node_modules/ts-node/src/index.ts:1459:23)
at Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Object.require.extensions.<computed> [as .ts] (/Users/hyunjaelee/work/commons-budget-contract/node_modules/ts-node/src/index.ts:1462:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/Users/hyunjaelee/work/commons-budget-contract/typechain-types/factories/@openzeppelin/contracts/utils/introspection/index.ts',
'/Users/hyunjaelee/work/commons-budget-contract/typechain-types/factories/@openzeppelin/contracts/utils/index.ts',
'/Users/hyunjaelee/work/commons-budget-contract/typechain-types/factories/@openzeppelin/contracts/index.ts',
'/Users/hyunjaelee/work/commons-budget-contract/typechain-types/factories/@openzeppelin/index.ts',
'/Users/hyunjaelee/work/commons-budget-contract/typechain-types/factories/index.ts',
'/Users/hyunjaelee/work/commons-budget-contract/typechain-types/index.ts',
'/Users/hyunjaelee/work/commons-budget-contract/test/VoteHelper.ts',
'/Users/hyunjaelee/work/commons-budget-contract/test/AdminAction.test.ts',
'/Users/hyunjaelee/work/commons-budget-contract/node_modules/hardhat/node_modules/mocha/lib/mocha.js',
'/Users/hyunjaelee/work/commons-budget-contract/node_modules/hardhat/node_modules/mocha/index.js',
'/Users/hyunjaelee/work/commons-budget-contract/node_modules/hardhat/builtin-tasks/test.js',
'/Users/hyunjaelee/work/commons-budget-contract/node_modules/hardhat/internal/core/tasks/builtin-tasks.js',
'/Users/hyunjaelee/work/commons-budget-contract/node_modules/hardhat/internal/core/config/config-loading.js',
'/Users/hyunjaelee/work/commons-budget-contract/node_modules/hardhat/internal/cli/cli.js'
]
}
12. Unexpected end of JSON input ์๋ฌ
- npx hardhat run scripts/deploy.ts --network devnet ์คํ์ ๋ฐ์
- ํด๊ฒฐ๋ฐฉ๋ฒ: ๊ทธ๋ฅ ํด๋ ์์ฒด๋ฅผ ์ง์ฐ๊ณ , git clone์ผ๋ก ์์ค๋ฅผ ๋ค์ ๋ฐ์
- artifacts๋ฅผ ์ง์๋ ์๋์์.
- ๊นจ๋ํ ์ํ์์ ์๋๋ ๊ฑธ ๋ณด๋, ๋ฆฌํ์งํ ๋ฆฌ์ ๊ฐ์ด ํ์ผ์ด ์ ๋ฆฌ๋ ์ํ์ด๋ฉด ์ ๋ ๊ฒ ๊ฐ์.
- ์๋ฌ ๋ด์ฉ
An unexpected error occurred:
SyntaxError: /Users/hyunjaelee/work/commons-budget-contract/artifacts/@openzeppelin/contracts/utils/Context.sol/Context.dbg.json: Unexpected end of JSON input
at JSON.parse (<anonymous>)
at /Users/hyunjaelee/work/commons-budget-contract/node_modules/jsonfile/index.js:33:18
at /Users/hyunjaelee/work/commons-budget-contract/node_modules/graceful-fs/graceful-fs.js:123:16
at FSReqCallback.readFileAfterClose [as oncomplete] (node:internal/fs/read_file_context:68:3)
13. HardhatError: HH103: Account 0x3e29aefa7af16625691a9fca4a7fff0624aabc6f is not managed by the node you are connected to.
- ๋ฐ์์์ : npx hardhat run scripts/set_owner.ts --network testnet
- ํด๊ฒฐ: hardhat.config.ts์์๋ง ์ธํ ํ ๊ณ์ ๋ง ์ฌ์ฉํ ์ ์์.
14. TypeError: Cannot read properties of undefined (reading 'sourceName')
- ๋ฐ์์์ :
yarn test๋ก fulfillOrder ํ ์คํธ - ํด๊ฒฐ: yarn add --dev hardhat@ir
- ์๋ฌ ์์ธ๋ด์ฉ
/Users/hyunjaelee/work/seaport/node_modules/hardhat/internal/hardhat-network/stack-traces/solidity-errors.js:111
return new SolidityCallSite(sourceReference.sourceName, sourceReference.contract, sourceReference.function !== undefined
^
TypeError: Cannot read properties of undefined (reading 'sourceName')
(Use `node --trace-uncaught ...` to show where the exception was thrown)
error Command failed with exit code 7.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
15. .
- Seaport ํ ์คํธ ์ฝ๋ ์์ฑ์ ๋ฌธ์ ์๊น
- ํ ์คํธ์ฝ๋์์ ์ปจํธ๋ํธ ํจ์ ํธ์ถ์ signer๋ก connectํด์ผํ๋๋ฐ ๊ทธ๋ฅ wallet์ผ๋ก connect ํจ
- Hardhat ๋คํธ์ํฌ์์ ์ฌ์ฉํ ๊ณ์ ์ hardhat.config.ts์ getAccountํจ์์์ ์ถ๊ฐํ๋ฉด ๋จ.
16. Uncaught ReferenceError: Buffer is not defined
์ฌ๊ธฐ ์คํ ์ค๋ฒํ๋ก์ฐ ์ฐธ์กฐ
import{ Buffer} from'buffer';
// @ts-ignorewindow.Buffer= Buffer;
- Error HH700: Artifact for contract "hardhat/console.sol:console" not found.
- npx hardhat clean ์คํ
- TestNet์์ Contract ๋ฐฐํฌ์ UND_ERR_CONNECT_TIMEOUT์ด ๋ฐ์
- ๋ค์๊ณผ ๊ฐ์ด ์ฒ๋ฆฌ๋จ
- RPC๋ฅผ ๋ค๋ฅธ ๋ ธ๋์ ๋ถ์
- ๋ฌธ์ ๊ฐ ์๊ธด ๋ ธ๋๋ฅผ ํธ๋์ญ์ ํ์ ๋ ๋ ค๋ฒ๋ฆผ
19. TestNet์์ Contract ๋ฐฐํฌ ์คํฌ๋ฆฝํธ ์คํ์ ๋ค์ ํ๋กฌํํธ๋ก ์ ๋จ์ด์ง๊ณ ๋จนํต]
- Nonce๊ฐ์ด ๊ผฌ์ฌ์ ๊ทธ๋ ๊ฒ ๋จ
- Nonce๊ฐ์ด ๊ผฌ์ธ ์ด์ ๋ ๋ด ๊ฐ์ธ ํ๋ก์ ํธ์ธ web2/nft-market์์ NonceManager๋ฅผ ์ฌ์ฉํ์ง ์์์ ์๊ธด ๋ฌธ์
- ์ผ๋จ ๋ฌธ์ ๊ฐ ์๊ธด ๊ณ์ (์ฆ Contract๋ฅผ ๋ฐฐํฌํ๋ ์ฃผ์)์์ ๋ค์ดํฐ๋ธ ํ ํฐ์ ๋ณด๋ด๊ธฐ ๋ช๋ฒํ๋ฉด ๋จ.
20. npm ERR! code EINTEGRITY
npm ERR! sha1-UzRK2xRhehP26N0s4okF0cC6MhU=sha512-XWwnNNFCuuSQ0m3r3C4LE3EiORltHd9M05pq6FOlVeiophzRbMo50Sbz1ehl8K3Z+jw9+vmgnXefY1hz8X+2wA== integrity checksum failed when using sha1: wanted sha1-UzRK2xRhehP26N0s4okF0cC6MhU=sha512-XWwnNNFCuuSQ0m3r3C4LE3EiORltHd9M05pq6FOlVeiophzRbMo50Sbz1ehl8K3Z+jw9+vmgnXefY1hz8X+2wA== but got sha512-XWwnNNFCuuSQ0m3r3C4LE3EiORltHd9M05pq6FOlVeiophzRbMo50Sbz1ehl8K3Z+jw9+vmgnXefY1hz8X+2wA== sha1-UzRK2xRhehP26N0s4okF0cC6MhU=. (42300 bytes)
- yarn install์ ์จ์ผํ๋ ๊ณณ์์ npm install์ ์ผ์๋ ๋ํ๋จ
21. Error: error:0308010C:digital envelope routines::unsupported
- ์๋ฌ ๋ด์ฉ $ hardhat compile --config ./hardhat.config.ts An unexpected error occurred:
Error: error:0308010C:digital envelope routines::unsupported
at new Hash (node:internal/crypto/hash:67:19)
at createHash (node:crypto:133:10)
at ripemd160 (/Users/hyunjaelee/work/pooh-land/node_modules/@ethersproject/sha2/src.ts/sha2.ts:14:29)
at new HDNode (/Users/hyunjaelee/work/pooh-land/node_modules/@ethersproject/hdnode/src.ts/index.ts:115:67)
at Function.HDNode._fromSeed (/Users/hyunjaelee/work/pooh-land/node_modules/@ethersproject/hdnode/src.ts/index.ts:258:16)
at Function.HDNode.fromMnemonic (/Users/hyunjaelee/work/pooh-land/node_modules/@ethersproject/hdnode/src.ts/index.ts:269:23)
at Function.Wallet.fromMnemonic (/Users/hyunjaelee/work/pooh-land/node_modules/@ethersproject/wallet/src.ts/index.ts:192:34)
at Function.Wallet.createRandom (/Users/hyunjaelee/work/pooh-land/node_modules/@ethersproject/wallet/src.ts/index.ts:177:23)
at getAccounts (/Users/hyunjaelee/work/pooh-land/hardhat.config.ts:35:26)
at Object.<anonymous> (/Users/hyunjaelee/work/pooh-land/hardhat.config.ts:116:17) {
opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
library: 'digital envelope routines',
reason: 'unsupported',
code: 'ERR_OSSL_EVP_UNSUPPORTED'
- node ๋ฒ์ 16์ ์ฌ์ฉํด์ผํ๋๋ฐ 18์ ์ฌ์ฉํ ๋ ๋ฌธ์ ๋ฐ์ํจ.
22. jiyoungminjung์ผ๋ก ์ฒ์์ push๋ฅผ ํ๋ ค๊ณ ํ ๋ ๊ถํ ๋ฌธ์ ๋ฐ์
- ์๋ฌ ๋ด์ฉ To github.com:jiyoungminjung/pooh-land-js.git ! [remote rejected] readme -> readme (permission denied) error: failed to push some refs to 'git@github.com:jiyoungminjung/pooh-land-js.git'
- ํด๊ฒฐ
- jiyoungminjung์ ๊ณ์ setting์์ SSH key๋ฅผ ๋ฑ๋กํจ.
23. BigInt ์ธ์ ๋ชปํ๋ ๋ฌธ์
๊ด๋ จ github repo: github.com:poohgithub/pooh-swap-v2-core.git
const swapTestCases: BigInt[][] = [
[1, 5, 10, '1662497915624478906'],
[1, 10, 5, '453305446940074565'],
[2, 5, 10, '2851015155847869602'],
[2, 10, 5, '831248957812239453'],
[1, 10, 10, '906610893880149131'],
[1, 100, 100, '987158034397061298'],
[1, 1000, 1000, '996006981039903216']
].map(a => a.map(n => (typeof n === 'string' ? BigInt(n) : BigInt(n * 10 ** 18))));
swapTestCases.forEach((swapTestCase, i) => {
it(`getInputPrices:${i}`, async () => {
const swapAmount = BigInt(swapTestCase[0].toString());
const token0Amount = BigInt(swapTestCase[1].toString());
const token1Amount = BigInt(swapTestCase[2].toString());
const expectedOutputAmount = BigInt(swapTestCase[3].toString());
await addLiquidity(token0Amount, token1Amount);
await token0.transfer(pair.target, swapAmount);
await expect(pair.swap(0, expectedOutputAmount + 1n, admin.address, '0x', overrides)).to.be.revertedWith('UniswapV2: K');
await pair.swap(0, expectedOutputAmount, admin.address, '0x', overrides);
});
});
Codes
Solidity์ address type์ด TypeScript์์๋ string
TypeScript ํ๋ก๊ทธ๋จ์ ํ๋ผ๋ฏธํฐ ์ถ๊ฐ
async function main() {
const parameter = process.env.PARAMETER;
console.log("Received parameter:", parameter);
// Your deployment or other script logic here
}
PARAMETER=value npx hardhat run deploy.ts
Agora Locanet ์คํ
- ์ฌ์ฉ์ root ํด๋์ git@github.com:bosagora/agoranet.git ์์ค ๋ค์ด๋ก๋((์ฌ์ฉ์ ๋ฃจํธ ํด๋์ ํด๋ก๋ ํด์ผํจ)
- cd ~/agoranet/michal/
- docker ์คํ
- cmd/el/init_node 1 ์คํ
- sudo๊ฐ ๋ค์ด๊ฐ ์์ด์ ๊ฐ์ธ PC ์ํธ๊ฐ ํ์ํจ.
- cmd/el/run_node 1
- LOCALNET_URL=http://127.0.0.1:8545 ยท chain id: 34559 ยท Admin์ ๋์ ๋ฃ์ด์ฃผ๊ธฐ
- ๋ฐฉ๋ฒ: ๋์ ์ด๋ฏธ ๊ฐ์ง๊ณ ์๋ ํค๋ฅผ ์ฃผ์ ๋ค๊ณ ํจ.
- 0xb16ae920b229e39555024802925f663071625a998cb1c0ecf88878841fa748e6 ยท CommonsBudget ๋ฐฐํฌ ยท config/el/genesis_bosagora.json์ ๋ค์๊ณผ ๊ฐ ์ธํ
- bosagoraBlock: ์ปค๋จผ์ค ๋ฒ์ง ๋ฐํ์ ์์๋ ๋ธ๋ญ, ๋ฐฐํฌ๋ ๋ธ๋ญ์ 20~30๊ฐ ์ดํ ์ ๋น.
- commonsBudget: ๋ฐฐํฌ๋ CommonsBudget Address
Subgraph ๊ฐ๋ฐ์ ๊ฑธ๋ฆฐ ์๊ฐ: ๋ฑ 10์ผ
๊ฐ์: ๋ฌธ์ ํ์ ์ด 3์ผ, ํ ์คํธ๊ฐ 4์ผ, ์ค์ ๊ฐ๋ฐ: 3์ผ Post Mortem
- ๋ฌธ์์ ๋ํ ์ข ๋ ๊ผผ๊ผผํ ๋ถ์์ด ํ์ ํ์.
- chatGPT๋ก ์ธํด์ ๊ฐ๋ฐ๊ธฐ๊ฐ์ด 1/3๋ก ๋จ์ถ๋จ
- ๋ชฉ/๊ธ/ํ(2/9~10, 2/14): Graph ๊ตฌ์กฐ ํ์
- ์(2/15): ์ค์ ์คํ ๊ด๋ จ ์๋ฃ ์กฐ์ฌ
- ๋ชฉ/๊ธ(2/16~17): Goerli/local ๋ ธ๋์์ ์์ ๋๋ ค๋ณด๊ธฐ
- ์(20): ํ ์คํธ๋ท ์์ ์ปจํธ๋ํธ ํ ์คํธ
- ํ/์(21~22): ERC1155/ERC721/AssetContract์ ๋ํ ํ ์คํธ ์๋ฃ
- ๋ชฉ(23): ํ ์คํธ๋ท์์ ์คํค๋ง ๋ฐ ๋งคํ 1์ฐจ ๊ฐ๋ฐ ์๋ฃ
hardhat ํ๋ก์ ํธ ๊ฐ๋ฐ์ ์ฐธ๊ณ
๊ฐ๋
- const receipt = await (await tx).wait(); ยง tx๋ sendTransaction()์์ ๋ฆฌํดํ Promise์ด๋ค.
Solidity version
ยท ๊ฐ์ฅ ํ์คํ ํํ โ pragma solidity >=0.8.0 <=0.8.10; ยท pragma solidity ^0.5.2; โ 0.5.2 ์ด์ ๋ฒ์ ์ปดํ์ผ๋ฌ๋ก๋ ์ปดํ์ผ ์๋จ โ 0.6.0 ์ผ๋ก ์์๋๋ ๋ฒ์ ์๋ ์ปดํ์ผ ์๋จ (^๊ฐ ๊ทธ๋ฐ ์๋ฏธ์)
harthat ํ๋ก์ ํธ ๋ง๋ค๊ธฐ
In our case we created the folder named ProjetoLivroNFTERC1155OZ.
- Start npm in standard mode. npm init -y
- Install the hardhat. npm install --save-dev hardhat yarn add --dev hardhat <== yarn์ผ๋ก ์ธ์คํจํ ๊ฒฝ์ฐ.
- Install OpenZeppelin smart contracts. npm install @openzeppelin/contracts
- Install required modules and dependencies. npm install --save-dev @nomiclabs/hardhat-waffle npm install --save-dev "@nomiclabs/hardhat-ethers@^2.0.0" "ethereum- waffle@^3.4.0" "ethers@^5.0.0"
- Install the dotenv module. npm install dotenv
- Start the hardhat. npx hardhat
delegatecall ๊ดํ์ฌ
Medium delegatecall Preventing Vulnerabilities in Solidity - Delegate Call Stackexchange Solidity storage Storage slot in Inheritance
pragma solidity ^0.8.0; import "hardhat/console.sol";
contract Executor { uint256 public luckyNumber; address public sender; uint256 public value;
function setLuckyNumber(uint256 _luckyNumber) public payable { luckyNumber = _luckyNumber; sender = msg.sender; value = msg.value; }
function showNumber() public { console.log("luckeyNumber:", luckyNumber); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "hardhat/console.sol"; contract Caller { function setLuckyNumber(address executor, uint256 _luckyNumber) public payable { (bool success, bytes memory data) = executor.delegatecall( abi.encodeWithSignature("setLuckyNumber(uint256)", _luckyNumber) ); } function showNumber(address executor) public { (bool success, bytes memory data) = executor.delegatecall( abi.encodeWithSignature("showNumber()") ); } }
static call
staticcall works in a similar way as a normal call (without any value (sending eth) as this would change state). But when staticcall is used, the EVM has a STATIC flag set to true. Then, if any state modification is attempted, an exception is thrown. Once the staticcall returns, the flag is turned off.
npm publish, NPM module ๋ฐฐํฌ, ๋ชจ๋ ๋ฐฐํฌ
- ๋ณธ์ธ์ npm node ํ๋ก์ ํธ ๋ฃจํธ ํด๋๋ฅผ ๋ค์ด๊ฐ์ "npm login" ๋ช ๋ น ์คํ
- NPM ํ์ด์ง์์ ๋ก๊ทธ์ธ ์งํ, Google Authenticator ํ์
- ๋ค์ ํ๋ก์ ํธ ๋ฃจํธ ํด๋์์ "npm publish" ๋ช ๋ น ์คํ
- NPM ํ์ด์ง์์ ๋ฐฐํฌ ์งํ, Google Authenticator ํ์
Transaction์ ํํ
transaction: { hash: '0x4508d350b89655c9452d527ff1b3d307ed566228661b0a805567561ebc7590f1', type: 2, accessList: [], blockHash: '0xb0f9792fbe40b2b9c85fbdabb90e7f0e4ee08f82f9f82ef485814d3002a34c8f', blockNumber: 59, transactionIndex: 0, confirmations: 1, from: '0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC', gasPrice: BigNumber { value: "1000591199" }, maxPriorityFeePerGas: BigNumber { value: "1000000000" }, maxFeePerGas: BigNumber { value: "1001182398" }, gasLimit: BigNumber { value: "211019" }, to: '0x09635F643e140090A9A8Dcd712eD6285858ceBef', value: BigNumber { value: "0" }, nonce: 3, data: '0xe7acab24000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000005600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000005000000000000000000000000000000000000000000000000000000000000046000000000000000000000000000000000000000000000000000000000000004c0000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb9226600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000160000000000000000000000000000000000000000000000000000000000000022000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000063be212dffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff3000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ea4da12fc3f3f34300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000006509f2a854ba7441039fce3b959d5badd2ffcfcd00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008ac7230489e800000000000000000000000000000000000000000000000000008ac7230489e800000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000300000000000000000000000033c0024ebc7a8989c1ae32988d5402295c8fd42b3c44cdddb6a900fa2b585dd299e03d12fa4293bc000000000000010000000064000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb9226600000000000000000000000000000000000000000000000000000000000000010000000000000000000000006509f2a854ba7441039fce3b959d5badd2ffcfcd000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003782dace9d9000000000000000000000000000000000000000000000000000003782dace9d9000000000000000000000000000070997970c51812dc3a010c7d01b50e0d17dc79c800000000000000000000000000000000000000000000000000000000000000401fb0dfbaf5bce7c5a92402efbcec0e173531b3e3378e7b236a83eda892e6ac0603ef19202e3b2217622f4a881609e592f598fde0d14849af8b0fb024b71de187000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007f688786', r: '0xe41292838da7454d5932feef08cb49c12e56721edfab2df873d79abaf35fed26', s: '0x2a9cf276597a3559d1784c95234ff0c0805e4b29e846ccbe13e59fb3f0874f2a', v: 0, creates: null, chainId: 1, wait: [Function (anonymous)] }
sendTransaction - hardhat ํ ์คํธ ์ฝ๋
const encodedData = feeCollectorContract.interface.encodeFunctionData( "unwrapAndWithdraw", [ feeAdmin.address.toString(), wboaContract.address, BigNumber.from("10") ] ); const result = await ownerSigner.sendTransaction({ to: proxyContract.address, data: encodedData });
- ๊ด๋ จ ์ฌ์ดํธ https://ethereum.stackexchange.com/questions/54845/calling-contract-function-via-web3-eth-sendtransaction-doesnt-work https://stackoverflow.com/questions/72584559/how-to-test-the-solidity-fallback-function-via-hardhat https://github.com/ethers-io/ethers.js/issues/478 https://ethereum.stackexchange.com/questions/114146/how-do-i-manually-encode-and-send-transaction-data https://github.com/ethers-io/ethers.js/issues/3522
Predicted Address
contract C {
functioncreateDSalted(bytes32 salt, uint arg) public {
// This complicated expression just tells you how the address
// can be pre-computed. It is just there for illustration.
// You actually only need new D{salt: salt}(arg).
address predictedAddress = address(uint160(uint(keccak256(abi.encodePacked(
bytes1(0xff),
address(this),
salt,
keccak256(abi.encodePacked(
type(D).creationCode,
abi.encode(arg)
))
)))));
D d = newD{salt: salt}(arg);
require(address(d) == predictedAddress);
}
}
}
์ปจํธ๋ํธ ์ฌ์ด์ฆ
1. npm install --dev hardhat-contract-sizer
2. hardhat.config.ts์ ๋ค์ ๋ผ์ธ ์ถ๊ฐ
โ import "hardhat-contract-sizer";
3. npx hardhat size-contracts
์๋ ๋ฐฉ์
solc-select install 0.8.0
truffle-config.js module.exports = { networks: { development: { host: "127.0.0.1", port: 8545, network_id: "*" // Match any network id } }, compilers: { solc: { version: "^0.8.0" } } };
data = fs.readFileSync('/Users/hyunjaelee/work/commons-budget-contract/build/contracts/VoteraVote.json'); obj = JSON.parse(data); size = Buffer.byteLength(obj.deployedBytecode) / 2;
Nonce ์ค๋ฅ ๊ด๋ จํด์ ํจ๋ฆฌ๋์ด ์๊ธฐํด์ค๊ฒ
private async resetTransactionCount() { this.manager_signer.setTransactionCount(await this.manager_signer.getTransactionCount()); } 3:42 nonce-manager.ts setTransactionCount(transactionCount: ethers.BigNumberish | Promise<ethers.BigNumberish>): void { this._initialPromise = Promise.resolve(transactionCount).then((nonce) => { return ethers.BigNumber.from(nonce).toNumber(); }); this._deltaCount = 0;
TODO: boa-space-contracts conduit ๊ด๋ จ assembly ์ฝ๋ (#conduit.spec.ts)
- ๊ด๋ จ์๋ฌ
Error: call revert exception [ See: https://links.ethers.org/v5-errors-CALL_EXCEPTION ] (method="getDomain(bytes4,uint256)")
`boa-space-contracts` ํ๋ก์ ํธ, conduit.spec.ts 1079๋ผ์ธ ์๋ฌ. ์์ธํ ๋ด์ฉ์ web/solidity.html์์ `#conduit.spec.ts`๋ก ๊ฒ์ => test.yml ์๋ณตํด์ ํด๋ณด๊ธฐ(Run Linters, Run Reference Tests, Run "
- conduit.spec.ts ์๋ ์ฝ๋์์ ์๋ฌ๋จ
it.only("Reverts when attempting to execute transfers on a conduit when not called from a channel", async () => {
const expectedRevertReason =
getCustomRevertSelector("ChannelClosed(address)") +
owner.address.slice(2).padStart(64, "0").toLowerCase();
const tx = await conduitOne.connect(owner).populateTransaction.execute([]);
const returnData = await provider.call(tx);
expect(returnData).to.equal(expectedRevertReason);
await expect(conduitOne.connect(owner).execute([])).to.be.reverted;
});
- Conduit.sol
modifier onlyOpenChannel() {
console.log("onlyOpenChannel");
// Utilize assembly to access channel storage mapping directly.
assembly {
// Write the caller to scratch space.
mstore(ChannelKey_channel_ptr, caller())
// Write the storage slot for _channels to scratch space.
mstore(ChannelKey_slot_ptr, _channels.slot)
// Derive the position in storage of _channels[msg.sender]
// and check if the stored value is zero.
if iszero(
sload(keccak256(ChannelKey_channel_ptr, ChannelKey_length))
) {
// The caller is not an open channel; revert with
// ChannelClosed(caller). First, set error signature in memory.
mstore(ChannelClosed_error_ptr, ChannelClosed_error_signature)
// Next, set the caller as the argument.
mstore(ChannelClosed_channel_ptr, caller())
// Finally, revert, returning full custom error with argument.
revert(ChannelClosed_error_ptr, ChannelClosed_error_length)
}
}
console.log("onlyOpenChannel return");
// Continue with function execution.
_;
}
Jay's code sneppets
latest forge
yarn cache clean --force
vm.expectRever(
abi.encodeWithSelector(
Raffle.Raffle__UpkeepNotNeeded.selector,
...
)
}
vm.recordLogs();
Vm.Log[] memory entries = vm.getRecordedLogs();
forge sanpshot -m testWithrawFromMultipleFunders
vm.txGasPrice(GAS_PRICE);
uint256 gasStart = gasleft();
uint256 gasEnd = gasleft();
uint256 gasUsed = (gasStart - gasEnd) * tx.gasprice;
forge inspect FundMe storageLayout
cast storage 0x...(Contract address) ์จ๋ณด๊ธฐ
cast --to-wei 15
cast balance 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045
๋ฐฐํฌ ์คํฌ๋ฆฝํธ ์คํ์์๋ --broadcast๋ฅผ ์จ์ผ ํจ.
cast --calldata-decode "fund()" 0xa7ea5e4e
ํ์ด์ ์ธํฐํ๋ฌํฐ ๋ชจ๋ ๊ฐ์ ๊ฒ.
chisel - Test and receive verbose feedback on Solidity inputs within a REPL environment.
latest hardhat
๊ธฐํ: reset array ๋ฑ
uint16 ํ์
๋ ์์.
constructor (..., vrfCoordinator, ...) VRFConsumerBaseV2(vrfCoordinator) {
...
}
% ์ฐ์ฐ์๋ ์์.
address payable winner = s_players[indexOfWinner];
resetting!
s_players = new address payable[](0);
event WinnerPicked(address indexed winner);
This allows these parameters to be searchable when looking through the blockchain logs.
abi.decode
function addPerson(bytes calldata data) external {
// Assuming `data` is ABI-encoded with (string, uint8)
(string memory name, uint8 age) = abi.decode(data, (string, uint8));
// Store the information in the contract's state
people[msg.sender] = Person(name, age);
// Emit an event to log the addition
emit PersonAdded(msg.sender, name, age);
}
slot.value
function upgrade(address implementation_) external virtual {
require(_isValidSigner(msg.sender), "Caller is not owner");
require(implementation_ != address(0), "Invalid implementation address");
++state;
StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = implementation_;
}
Promise.all && map
await Promise.all(Array.from({ length: 14 }, (_, i) => i).map((i) => claimTopicsRegistry.addClaimTopic(i)));
signMessage
// ์ด๊ฑด ethers v5์ฉ์ด๋ผ ์ฐธ๊ณ ์ฉ
claimForBob.signature = await claimIssuerSigningKey.signMessage(
ethers.utils.arrayify(
ethers.utils.keccak256(
ethers.utils.defaultAbiCoder.encode(['address', 'uint256', 'bytes'], [claimForBob.identity, claimForBob.topic, claimForBob.data]),
),
),
);
// ethers v6
const signature = await signer.signMessage(
ethers.toBeArray(
ethers.solidityPackedKeccak256(
["bytes32", "address", "uint256"],
[
SIGNATURE_DELEGATION_HASH_TYPE,
delegates[index]!.address,
endTimestamp,
],
),
),
);
์ฐธ๊ณ ํ ๋ด์ฉ ๋ง์
function cheaperWithdraw() public onlyOwner {
address[] memory funders = s_funders;
// mappings can't be in memory, sorry!
for (uint256 funderIndex = 0; funderIndex < funders.length; funderIndex++) {
address funder = funders[funderIndex];
s_addressToAmountFunded[funder] = 0;
}
s_funders = new address[](0);
// payable(msg.sender).transfer(address(this).balance);
(bool success,) = i_owner.call{value: address(this).balance}("");
require(success);
}
CALLDATA
CALLDATACOPY(t, f, s): msg.data ์ f๋ฒ์งธ ์์น์์ s๊ฐ์ ๋ฐ์ดํธ๋ฅผ ์ฝ์ด ๋ฉ๋ชจ๋ฆฌ์ t๋ฒ์งธ ์์น์ ์ ์ฅํฉ๋๋ค.
create2(
callvalue(), // wei sent with current call
// Actual code starts after skipping the first 32 bytes
add(bytecode, 0x20),
(bytecode), // Load the size of code contained in the first 32 bytes
_salt // Salt from function arguments
)
Make sure that we can transfer out token 200
vm.prank(owner4);
IERC6551Executable(account4).execute(
address(account3),
0,
abi.encodeWithSignature(
"execute(address,uint256,bytes,uint8)",
address(nft),
0,
abi.encodeWithSignature(
"safeTransferFrom(address,address,uint256)", account3, newTokenOwner, 200
),
0
),
0
);
function callTransfer(address _token, address _to, uint256 _amount) external {
// This will encode the function call to `transfer(address,uint256)` with the specified arguments
bytes memory data = abi.encodeWithSignature("transfer(address,uint256)", _to, _amount);
// Making the actual call to the token contract's transfer function
(bool success, ) = _token.call(data);
require(success, "Transfer failed");
}
Nick's Factory
The registry MUST be deployed at address 0x000000006551c19487814612e58FE06813775758 using Nickโs Factory (0x4e59b44847b379578588920cA78FbF26c0B4956C) with salt 0x0000000000000000000000000000000000000000fd8eb4e1dca713016c518e31.
The registry can be deployed to any EVM-compatible chain using the following transaction:
{
"to": "0x4e59b44847b379578588920ca78fbf26c0b4956c",
"value": "0x0",
"data": "0x0000000000000000000000000000000000000000fd8eb4e1dca713016c518e31608060405234801561001057600080fd5b5061023b806100206000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c8063246a00211461003b5780638a54c52f1461006a575b600080fd5b61004e6100493660046101b7565b61007d565b6040516001600160a01b03909116815260200160405180910390f35b61004e6100783660046101b7565b6100e1565b600060806024608c376e5af43d82803e903d91602b57fd5bf3606c5285605d52733d60ad80600a3d3981f3363d3d373d3d3d363d7360495260ff60005360b76055206035523060601b60015284601552605560002060601b60601c60005260206000f35b600060806024608c376e5af43d82803e903d91602b57fd5bf3606c5285605d52733d60ad80600a3d3981f3363d3d373d3d3d363d7360495260ff60005360b76055206035523060601b600152846015526055600020803b61018b578560b760556000f580610157576320188a596000526004601cfd5b80606c52508284887f79f19b3655ee38b1ce526556b7731a20c8f218fbda4a3990b6cc4172fdf887226060606ca46020606cf35b8060601b60601c60005260206000f35b80356001600160a01b03811681146101b257600080fd5b919050565b600080600080600060a086880312156101cf57600080fd5b6101d88661019b565b945060208601359350604086013592506101f46060870161019b565b94979396509194608001359291505056fea2646970667358221220ea2fe53af507453c64dd7c1db05549fa47a298dfb825d6d11e1689856135f16764736f6c63430008110033",
}
assembly ๊ตฌ์กฐ
# Asssembly ๊ตฌ์กฐ
// Memory Layout:
// ----
// 0x00 0xff (1 byte)
// 0x01 registry (address) (20 bytes)
// 0x15 salt (bytes32) (32 bytes)
// 0x35 Bytecode Hash (bytes32) (32 bytes)
// ----
// 0x55 ERC-1167 Constructor + Header (20 bytes)
// 0x69 implementation (address) (20 bytes)
// 0x5D ERC-1167 Footer (15 bytes)
// 0x8C salt (uint256) (32 bytes)
// 0xAC chainId (uint256) (32 bytes)
// 0xCC tokenContract (address) (32 bytes)
// 0xEC tokenId (uint256) (32 bytes)
// Silence unused variable warnings
pop(chainId)
// Copy bytecode + constant data to memory
calldatacopy(0x8c, 0x24, 0x80) // salt, chainId, tokenContract, tokenId
mstore(0x6c, 0x5af43d82803e903d91602b57fd5bf3) // ERC-1167 footer
mstore(0x5d, implementation) // implementation
mstore(0x49, 0x3d60ad80600a3d3981f3363d3d373d3d3d363d73) // ERC-1167 constructor + header
// Copy create2 computation data to memory
mstore8(0x00, 0xff) // 0xFF
mstore(0x35, keccak256(0x55, 0xb7)) // keccak256(bytecode)
mstore(0x01, shl(96, address())) // registry address
mstore(0x15, salt) // salt
// Compute account address
let computed := keccak256(0x00, 0x55)
// If the account has not yet been deployed
if iszero(extcodesize(computed)) {
// Deploy account contract
let deployed := create2(0, 0x55, 0xb7, salt)
// Revert if the deployment fails
if iszero(deployed) {
mstore(0x00, 0x20188a59) // `AccountCreationFailed()`
revert(0x1c, 0x04)
}
// Store account address in memory before salt and chainId
mstore(0x6c, deployed)
// Emit the ERC6551AccountCreated event
log4(
0x6c,
0x60,
// `ERC6551AccountCreated(address,address,bytes32,uint256,address,uint256)`
0x79f19b3655ee38b1ce526556b7731a20c8f218fbda4a3990b6cc4172fdf88722,
implementation,
tokenContract,
tokenId
)
// Return the account address
return(0x6c, 0x20)
}
// Otherwise, return the computed account address
mstore(0x00, shr(96, shl(96, computed)))
return(0x00, 0x20)
- ์ผ๋จ ๊นํ ์ปค๋ฐ ๋ฉ์์ง๋ ๋๋ฌธ์๋ก ํ๊ธฐ
- PR์ Motivation๊ณผ Solution์ผ๋ก ๋๋์ด ๊ธฐ์ ํ๊ธฐ
- ์ฝ๋
(address signer, ECDSA.RecoverError err) =
userOpHash.toEthSignedMessageHash().tryRecover(userOp.signature);
if (err != ECDSA.RecoverError.NoError) {
revert InvalidSignature();
}
- sol ํ์ผ ํจ์ ์ค๋ช
/// @title Base Session Key Plugin
/// @author Decipher ERC-6900 Team
/// @notice This plugin allows some designated EOA or smart contract to temporarily
/// own a modular account.
/// This base session key plugin acts as a 'parent plugin' for all specific session
/// keys. Using dependency, this plugin can be thought as a proxy contract that stores
/// session key duration information, but with validation functions for session keys.
///
/// It allows for session key owners to access MSCA both through user operation and
/// runtime, with its own validation functions.
/// @notice Route call to executeFromPluginExternal at the MSCA.
/// @dev This function will call with value = 0, since sending ether
/// for ERC20 contract is not a normal case.
/// @param target The target address to execute the call on.
/// @param data The call data to execute.
์๊ฒ๋ ๊ด์ฐฎ๋ค: https://github.com/erc6900/reference-implementation/pull/22/commits/0fb2113a0f1b09e8eeef72dd6d04b04bbc0151a8
โโ // โโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
// โ Execution functions โ
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
/// @inheritdoc ISessionKeyPlugin
function addTemporaryOwner(address tempOwner, uint48 _after, uint48 _until) external {
PR์ ์ค๋ช ๋ฌ๊ธฐ
## Motivation
We would like to accumulate the money for Poohnet Fund which will be used to support the real world projects which have content to make our world friendly.
## Solution
commit 789c3cf6c : Change the code for generating inflation for Poohnet Fund
commit c595c22a9 : Apply configuration for make the inflation start
supportsInterface
function supportsInterface(bytes4 interfaceId) public view override returns (bool) {
return interfaceId == type(ISessionKeyPlugin).interfaceId || super.supportsInterface(interfaceId);
}
storage modifier
EnumerableSet.Bytes32Set storage sessionKeySet = _sessionKeySet[msg.sender]; Purpose: This line declares a variable sessionKeySet that refers to a set of session keys for the message sender (msg.sender). The storage modifier indicates that sessionKeySet is a pointer to the data located in the contract's persistent storage, not a temporary copy. This is crucial in Solidity because changes to a storage variable directly modify the state on the blockchain.
unchecked block
The unchecked block is used here to tell the compiler not to check for overflows when incrementing the index i. This can save gas since the overflow is unlikely given the controlled environment of the loop (i.e., looping over an array length
transient storage sample
https://solidity-by-example.org/transient-storage/
forge create
npx hardhat node // ๊ผญ hardhat ํ๋ก์ ํธ ํด๋์์ ์งํํด์ผํจ.
forge script script/DeployTransactionDelegator.s.sol --rpc-url $LOCALNET_RPC_URL
CREATE a CONTRACT with 2 SAME addresses on 2 DIFFERENT chains
address = bytes20(keccak256(0xFF, senderAddress, salt, bytecode))
How to deploy my contract on 2 different chains with the same address? Now, letโs answer to the question: How to deploy a smart contract with the same addresses in 2 different chains?
You can do it with the CREATE2 opcode by providing the same salt on different chains. (easier than providing the nonce because you canโt fully control it)
foundry remapping์ toml์์ ์ง์ ํจ.
tokenURI ํจ์, ERC721
forge init โforce forge install https://github.com/OpenZeppelin/openzeppelin-contracts@v4.9.3
Fatal: Failed to write genesis block: database contains incompatible genesis
==> ์๋ genesis_testnet.json๊ณผ genesis_fund_testnet์ ์๋ ๋ถ๋ถ์ด ๋ค๋ฆ
"difficulty": "1",
"gasLimit": "8000000",
"extradata": "0x00000000000000000000000000000000000000000000000000000000000000008532654aD638Db3deE3836B22B35f7Ca707428ca0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"alloc": {
// ์ค๋ต
}
}
OnlyHardhatNetworkError: This helper can only be used with Hardhat Network. You are connected to 'localnet', whose identifier is 'Geth/v1.12.1-unstable-5e198bde-20240602/darwin-amd64/go1.21.3'
at checkIfDevelopmentNetwork (/Users/hyunjaelee/work/web/ex/node_modules/@nomicfoundation/hardhat-network-helpers/src/utils.ts:29:11)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at async getHardhatProvider (/Users/hyunjaelee/work/web/ex/node_modules/@nomicfoundation/hardhat-network-helpers/src/utils.ts:40:3)
at async Object.latest (/Users/hyunjaelee/work/web/ex/node_modules/@nomicfoundation/hardhat-network-helpers/src/helpers/time/latest.ts:7:20)
at async deployOneYearLockFixture (/Users/hyunjaelee/work/web/ex/test/basic.spec.localnet.ts:24:25)
at async loadFixture (/Users/hyunjaelee/work/web/ex/node_modules/@nomicfoundation/hardhat-network-helpers/src/loadFixture.ts:59:18)
at async Context.<anonymous> (/Users/hyunjaelee/work/web/ex/test/basic.spec.localnet.ts:37:36)
info
- 2023.06.07 Fri
- test code๋ฅผ ๋ก์ปฌ๋ท์์ ์คํ์ํค๋๊น ๋ฌธ์ ๊ฐ ๋ฐ์ํจ.
- web3_clientVersion ๊ด๋ จ ์์.
version.toLowerCase().startsWith("hardhatnetwork") ||
version.toLowerCase().startsWith("anvil");
- ๋ด geth code์ web3_clientVersion ์ฝ๋๋ฅผ ๋ฐ๊ฟ์ผ ๊ฐ๋ฅํจ.
- anvill ์ฝ๋ ๋ณด๋ฉด ๊ธ๋ฐฉ ๋ฐ๊ฟ ์ ์์ ๊ฒ์ผ๋ก ๋ณด์.
TypeError: Cannot read properties of undefined (reading 'provider')
at Object.<anonymous> (/Users/hyunjaelee/work/web/ex/test/create2/base.spec.ts:5:25)
at Module._compile (node:internal/modules/cjs/loader:1364:14)
at Module.m._compile (/Users/hyunjaelee/work/web/ex/node_modules/ts-node/src/index.ts:1618:23)
at Module._extensions..js (node:internal/modules/cjs/loader:1422:10)
at Object.require.extensions.<computed> [as .ts] (/Users/hyunjaelee/work/web/ex/node_modules/ts-node/src/index.ts:1621:12)
at Module.load (node:internal/modules/cjs/loader:1203:32)
at Function.Module._load (node:internal/modules/cjs/loader:1019:12)
at Module.require (node:internal/modules/cjs/loader:1231:19)
at require (node:internal/modules/helpers:177:18)
at /Users/hyunjaelee/work/web/ex/node_modules/mocha/lib/mocha.js:414:36
error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
hardhat.config.ts์ ์๋ ์ถ๊ฐ
import '@nomiclabs/hardhat-waffle' import '@typechain/hardhat' import { HardhatUserConfig } from 'hardhat/config' import 'hardhat-deploy' import '@nomiclabs/hardhat-etherscan'
TypeError: Cannot read properties of undefined (reading 'provider'):
์ด๋ฐ ์๋ฌ๊ฐ ๋จ์ด์ง๋ ์ด์ ๊ฐ ์๋ import ๋ฌธ ๋๋ฌธ์ธ๋ฐ,
import { ethers } from โhardhatโ
hardhat์ ethers ๋ฒ์ ์ ๋ด๊ฐ ์ฐ๋ ค๋ ๋ฒ์ ๋ณด๋ค ๋ฎ์์ ๊ทธ๋ฐ ๊ฒ์ด๋ค. ์๋์ ๊ฐ์ด ๋ฐ๊พธ๋ฉด ๋จ.
import { ethers } from "ethers";
hardhat์ ethers ๋ฒ์ ๊ณผ ๋์ ethers ๋ฒ์ ์ด ๋ค๋ฅด๋ฉด ๋ ๋ฌธ์ ๊ฐ ์๊น.
const provider = ethers.provider;
signer = await ethers.getSigner();
์์์ ๋ฐ์ํ๋ โTypeError: Cannot read properties of undefined (reading 'provider')โ ๋ฌธ์ ๋ ๋ชจ๋ ์๋์ ์ฐ๊ด์ด ์๋ ๊ฒ์ด๊ณ ,
ethers: typeof ethers & HardhatEthersHelpers;
์ด๊ฒ์ hardhat.config.ts์ import "@nomicfoundation/hardhat-toolbox"; ์ถ๊ฐํด์ผ ํจ.
๊ฒฐ๊ตญ provider์ getSigner๋ hardhat.config.ts์ ๊ด๋ จ๋ ๊ฒ์ด์์.
TypeError: Cannot read properties of undefined (reading 'waitForTransaction')
await expect(execAccount.executeUserOp(userOp, 1)).to.emit(execAccount, "Executed").withArgs("Got it!", hashedMessage);
TypeError: Cannot read properties of undefined (reading 'waitForTransaction')
at waitForPendingTransaction (node_modules/@nomicfoundation/hardhat-chai-matchers/src/internal/emit.ts:34:19)
at /Users/hyunjaelee/work/web/ex/node_modules/@nomicfoundation/hardhat-chai-matchers/src/internal/emit.ts:84:21
- @nomicfoundation/hardhat-chai-matchers ๋ฒ์ ์ ^1.0.6 -> ^2.0.7 ์ฌ๋ฆผ
- ๊ณผ์ฐ ์๋ก ๋ค๋ฅธ ํจํค์ง๋ฅผ ํ์์ ํฌํจ์ํฌ๋ ์ด๋ป๊ฒ ๋๋์ง ํ์ธํ๊ธฐ: ๊ฐ์์ ํจ์งํค๋ฅผ ์ฌ์ฉํ๋๋ฐ, Peer-dependency๋ฅผ ๊ฐ์ ํ๋ ๊ฒฝ์ฐ๋ ์์ง.
"ethers": "^6.1.0", <== ์์์ ์ค์น๋จ
TypeError: (0 , ethers_1.getAddress) is not a function
hardhat์ ethers๋ฅผ ์ธ๋ ์ด๋ฐ์ผ์ด ๋ฐ์ํจ์ผ๋ก 6.7.0์ ์จ์ผํจ. ๊ทธ๋ ๋ค๋ฉด hardhat์ ๋ด ethers๋ฅผ ์ด๋ค๋ ์๊ธฐ? ๋ด๊บผ ์ฐ๋๊ฒ ๋ง์. ๊ทธ๋ฌ๋ฉด ๋ญํ๋ฌ import { ethers } from "hardhat"; ์ด๊ฑธ์ฐ๋๊ตฌ??? ์ด์จ๋ hardhat์ node_modules์๋ hardhat ๊น๋ฆฌ๊ฒ ์์.
forge install ํ ๋, .gitmodules๊ฐ ํ์ํจ
forge init โforce
forge install OpenZeppelin/openzeppelin-contracts
forge test --match-contract PoohnetFund
forge test --match-contract PoohnetFund --fork-url $LOCALNET_RPC_URL
forge test --match-path test/forge/FulfillBasicOrderTest.sol --gas-report
source code
import "@openzeppelin/contracts/utils/Create2.sol";
address fundContractAddr = vm.envAddress(
"POOHNET_FUND_CONTRACT_ADDRESS"
);
command
console.log(balance of deployer: ${await provider.getBalance(deployer.address)});
console.log(Receipt: ${JSON.stringify(receipt)});
const tx = await deployerListSetStore.addValue(valueData);
CONTRACT="AllBasic" yarn contract --network localnet
function _getListValue(uint240 value) internal pure returns (SetValue) { return SetValue.wrap(bytes30(value)); }
byte(0, mload(add(sig, 96))) extracts the first byte of this 32-byte value, because 0 is the index for the first byte.
// Clear any dirty upper bits of address ์์๋นํธ๊ฐ ์ง์์ง์ ์ฃผ์ addr := and(addr, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)
https://github.com/ethereum/solidity/releases
expect(receipt?.status).to.equal(1); ์ด๋ ๊ฒ ํด์ผ ๋นจ๊ฐ์ค์ด ์์๊น
slot := keccak256(keyBuffer, 0x80) // Solidity keccack256๊ณผ๋ ์ข ๋ค๋ฆ.
function executeUserOp ๋ฆฌํด๊ฐ์ ์ฒดํฌํ์ง ๋ชปํ๋ ๋ฌธ์ In view and pure functions, which are called statically from a local node without a transaction. Or when doing such a static call to any function, but knowing that the state changes are not persisted.
๋๊ฐ์ ์ฐจ์ด ==> ์ฒซ๋ฒ์ฌ๊ฒ ์ค๋ช
: This expression generally means you are waiting for the expect function (a promise) to resolve. This is typically used with assertion libraries like Chai when you are expecting a promise to be rejected or resolved in a certain way.
await expect(execAccount.executeUserOp(userOp, 1)).to.emit(execAccount, "Executed").withArgs("Got it!", hashedMessage);
expect(await execAccount.executeUserOp(userOp, 1)).to.emit(execAccount, "Executed").withArgs("Got it!", hashedMessage);
contract size
- limit: 24,576 bytes (24 KB).
- ๋น ํจ์ ํ๋ ์ถ๊ฐํ๋ฉด 23๋ฐ์ดํธ ์ถ๊ฐ๋จ ==> function addNone() public {}
- ํ๋ฌ์ค ์ฐ์ฐํ๋ ์ฝ๋ ํ๋ ์ถ๊ฐํ๋ฉด 26๋ฐ์ดํธ ์ถ๊ฐ๋จ ==> value2 += 62;
- Warning: 3 contracts exceed the size limit for mainnet deployment (24.000 KiB deployed, 48.000 KiB init).
const contractCode = await provider.getCode(tooBig.address);
const contractSize = (contractCode.length - 2) / 2; // Subtract 2 for '0x' prefix and divide by 2 to get the byte count
์๋์ isPrime์ฒ๋ฆฌ ์ฝ๋๋ฅผ library call ํ๋ ๊ฒ์ผ๋ก ๋ฐ๊พธ๋ฉด 200bytes ์ฐจ์ด, ๊ทธ๋ฅ ์์ ๋ฉด 500๋ฐ์ดํธ ์ฐจ์ด.
function addSixtyTwo(uint256 n) public returns (bool) {
// return n.isPrime();
if (n <= 1) return false;
if (n <= 3) return true;
if (n % 2 == 0 || n % 3 == 0) return false;
for (uint256 i = 5; i * i <= n; i += 6) {
if (n % i == 0 || n % (i + 2) == 0) return false;
}
return true;
}
solc --bin --abi contracts/assembly/DataStorage.sol -o output
npx hardhat node
// Call transfer function and check for success/failure (bool sent, ) = _to.call{value: msg.value}(""); require(sent, "Failed to send Ether");
yarn init -y yarn add typescript ts-node @types/node --dev tsc --init
error: externally-managed-environment
ร This environment is externally managed โฐโ> To install Python packages system-wide, try brew install xyz, where xyz is the package you are trying to install.
==> python3 -m pip config set global.break-system-packages true
ModuleNotFoundError: No module named 'web3' python3 -m pip --version
python3 -m pip install web3
curl v4.ident.me
๐ ์๋ Frequent Use(์ Memory) ๐
๐๐๐๐๐๐๐๐๐๐๐๐๐๐๐๐๐๐๐๐๐๐๐๐๐๐๐๐๐๐
forge script script/poohnet-fund/DeployPoohnetFund.s.sol --rpc-url localnet --private-key $PRIVATE_KEY --broadcast
cast call $POOHNET_FUND_CONTRACT_ADDRESS "getOwner()" --rpc-url $LOCALNET_RPC_URL
cast balance 0xE024589D0BCd59267E430fB792B29Ce7716566dF --rpc-url $LOCALNET_RPC_URL
cast send $POOHNET_FUND_CONTRACT_ADDRESS --value 2ether --private-key $PRIVATE_KEY
cast send $POOHNET_FUND_CONTRACT_ADDRESS "transferBudget(address,uint256)" 0xE024589D0BCd59267E430fB792B29Ce7716566dF 1000000000000000000 --rpc-url $LOCALNET_RPC_URL --private-key $PRIVATE_KEY
cast balance 0xE024589D0BCd59267E430fB792B29Ce7716566dF --rpc-url http://localhost:8545
cast sig "calculatePower(uint256,uint256)"
cast storage 0xCada01dfasdfa03a0Da2343bc0daF 0 <=
cast chain-id --rpc-url https://rpc.ankr.com/bsc
cast tx 0x3f6da406747a55797a7f84173cbb243f4fd929d57326fdcfcf8d7ca55b75fe99 --rpc-url https://rpc.ankr.com/bsc
cast block --help
cast 4byte 88303dbd <= signame ๊ฐ์ ธ์ค๊ธฐ cast sig 'buyTickets(uint256,uint32[])' <= sig ๊ฐ์ ธ์ค๊ธฐ
cast --calldata-decode