{"id":25249521,"url":"https://github.com/provable-things/ptokens-erc20-vault","last_synced_at":"2025-10-26T22:31:11.680Z","repository":{"id":39971712,"uuid":"295774746","full_name":"provable-things/ptokens-erc20-vault","owner":"provable-things","description":"The pToken pERC20-on-EOS smart-contract \u0026 management CLI.","archived":false,"fork":false,"pushed_at":"2023-05-17T12:53:34.000Z","size":1650,"stargazers_count":2,"open_issues_count":5,"forks_count":3,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-04-21T19:52:55.202Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/provable-things.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-09-15T15:43:50.000Z","updated_at":"2023-05-16T06:38:56.000Z","dependencies_parsed_at":"2022-08-31T16:25:40.767Z","dependency_job_id":null,"html_url":"https://github.com/provable-things/ptokens-erc20-vault","commit_stats":null,"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/provable-things%2Fptokens-erc20-vault","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/provable-things%2Fptokens-erc20-vault/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/provable-things%2Fptokens-erc20-vault/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/provable-things%2Fptokens-erc20-vault/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/provable-things","download_url":"https://codeload.github.com/provable-things/ptokens-erc20-vault/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238405181,"owners_count":19466450,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-02-12T03:22:24.850Z","updated_at":"2025-10-26T22:31:11.230Z","avatar_url":"https://github.com/provable-things.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# :page_with_curl: Provable pToken ERC20 Vault Smart-Contract\n\nThis repo houses the upgradeable ERC20-Vault logic smart-contract, as well as a simple CLI to help with deployment, verification \u0026 interacting with it.\n\n\u0026nbsp;\n\n## :boom: Usage Guide:\n\nAfter cloning the repository, first install the dependencies:\n\n```\n\u003e npm ci\n```\n\nThen, to see the usage guide, run:\n\n```\n\u003e ./cli.js --help\n```\n\nOutput:\n\n```\n❍ pTokens ERC20 Vault Command Line Interface\n\n  Copyright Provable Things 2021\n  Questions: greg@oraclize.it\n\n❍ Info:\n\n  A tool to aid with deployments of \u0026 interactions with the upgradeable pToken ERC20 vault logic contract.\n\n  NOTE: Functions that make transactions require a private key. Please provide a GPG encrpyted file called\n    'private-key.gpg' containing your key in the root of the repository. Create one via:\n    'echo \u003cyour-private-key\u003e | gpg -c --output private-key.gpg'\n    Multiple private keys may be provisioned, and the tool will provide you with a list to select from.\n\n  NOTE: The tool requires a '.env' file to exist in the root of the repository with the following info:\n    ENDPOINT=\u003crpc-endpoint-for-blochain-to-interact-with\u003e\n    Multiple such files may be provisioned, and the tool will provide you with a list to select from.\n\n  NOTE: To call functions which verify contracts, the following extra environment variable is required:\n    ETHERSCAN_API_KEY=\u003capi-key-for-automated-contract-verifications\u003e\n\n❍ Usage:\n  cli.js --help\n  cli.js --version\n  cli.js flattenContract\n  cli.js showSuggestedFees\n  cli.js showWalletDetails\n  cli.js deployVaultContract\n  cli.js showExistingContracts\n  cli.js getPNetwork \u003cdeployedAddress\u003e\n  cli.js getWEthAddress \u003cdeployedAddress\u003e\n  cli.js getSupportedTokens \u003cdeployedAddress\u003e\n  cli.js deployUnwrapperContract \u003cwEthAddress\u003e\n  cli.js setPNetwork \u003cdeployedAddress\u003e \u003cethAddress\u003e\n  cli.js verifyVaultContract \u003cnetwork\u003e \u003cdeployedAddress\u003e\n  cli.js isTokenSupported \u003cdeployedAddress\u003e \u003cethAddress\u003e\n  cli.js addSupportedToken \u003cdeployedAddress\u003e \u003cethAddress\u003e\n  cli.js setWEthUnwrapperAddress \u003cdeployedAddress\u003e \u003cethAddress\u003e\n  cli.js verifyUnwrapperContract \u003cnetwork\u003e \u003cdeployedAddress\u003e \u003cwEthAddress\u003e\n  cli.js encodeInitArgs \u003cwEthAddress\u003e \u003coriginChainId\u003e [--token=\u003cethAddress\u003e...]\n  cli.js pegIn \u003cdeployedAddress\u003e \u003camount\u003e \u003ctokenAddress\u003e \u003cdestinationAddress\u003e \u003cdestinationChainId\u003e [--userData=\u003chex\u003e]\n\n❍ Commands:\n  setPNetwork              ❍ Set the pNetwork address.\n  showSuggestedFees        ❍ Show 'ethers.js' suggested fees.\n  deployUnwrapperContract  ❍ Deploy the WETH unwrapper contract.\n  deployVaultContract      ❍ Deploy the ERC20 vault logic contract.\n  verifyVaultContract      ❍ Verify a deployed pToken logic contract.\n  verifyUnwrapperContract  ❍ Verify a deployed WETH unwrapper contract.\n  getPNetwork              ❍ Show the pNetwork address of the vault at \u003cdeployedAddress\u003e.\n  getWEthAddress           ❍ Show the wETH address set in the vault at \u003cdeployedAddress\u003e.\n  flattenContract          ❍ Flatten the contract in case manual verification is required.\n  getSupportedTokens       ❍ Show list of tokens supprted by the vault at \u003cdeployedAddress\u003e.\n  showWalletDetails        ❍ Decrypts the private key and shows address \u0026 balance information.\n  isTokenSupported         ❍ Is token at \u003cethAddress\u003e supported in vault at \u003cdeployedAddress\u003e.\n  encodeInitArgs           ❍ Calculate the initializer function arguments in ABI encoded format.\n  showExistingContracts    ❍ Show list of existing logic contract addresses on various blockchains.\n  addSupportedToken        ❍ Adds token at \u003cethAddress\u003e to the supported tokens in vault at \u003cdeployedAddress\u003e.\n  pegIn                    ❍ Peg in \u003camount\u003e of \u003ctokenAddress\u003e to \u003cdestinationAddress\u003e on \u003cdestinationChainId\u003e.\n  setWEthUnwrapperAddress  ❍ Sets the WETH unwrapper contract at \u003cethAddress\u003e in the vault at \u003cdeployedAddress\u003e.\n\n❍ Options:\n  --help                   ❍ Show this message.\n  --version                ❍ Show tool version.\n  \u003cethAddress\u003e             ❍ A valid ETH address.\n  \u003ctokenAddress\u003e           ❍ ETH address of token.\n  \u003cdeployedAddress\u003e        ❍ The ETH address of the deployed vault.\n  \u003cdestinationAddress\u003e     ❍ Destination address of a token peg in.\n  --userData=\u003chex\u003e         ❍ User data in hex format [default: 0x].\n  --token=\u003cethAddress\u003e     ❍ ETH addresses of tokens the vault will support.\n  \u003camount\u003e                 ❍ Amount of tokens in their most granular format.\n  \u003coriginChainId\u003e          ❍ Metadata chain ID of the chain this contract is deployed to.\n  \u003cdestinationChainId\u003e     ❍ Metadata chain ID of the chains this contract supports peg-ins to.\n  \u003cwEthAddress\u003e            ❍ The address for the wrapped ETH token on the blockchain to be deployed to.\n  \u003cnetwork\u003e                ❍ Network the vault is deployed on. It must exist in the 'hardhat.config.json'.\n\n```\n\n\u0026nbsp;\n\n### :black_nib: Notes:\n\n - To simplify deployments, the tool uses __`ethers.js`__ suggested fees for deployment. The CLI function __`showSuggestedFees`__ will show you the currently suggested fees, including __[EIP1559](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1559.md)__ specific values if the chain you're working with is EIP1559 compaible.\n\n - In case the chain you're deploying to does not have etherscan-style contract verification which works with the hardhat plugin, there exists the __`flattenContract`__ command. This will flatten the __`pToken`__ contract into a single __`.sol`__ file that can then be used for manual verification.\n\n\u0026nbsp;\n\n### :guardsman: Smart-Contract Tests:\n\n1) Install dependencies\n\n```\n❍ npm ci\n```\n\n2) Run the tests via:\n\n```\n❍ npm run tests\n```\n\nTest output:\n\n```\n\n  Erc20Vault Tests\n    Initalizer Tests\n      ✓ Token addresses sent to constructor should be supported (250ms)\n    Ownership Tests\n      ✓ PNETWORK_ADDRESS can change PNETWORK_ADDRESS (55ms)\n      ✓ NON_PNETWORK_ADDRESS cannot change PNETWORK_ADDRESS (62ms)\n      ✓ Should not be able to set pNetwork address to the zero address\n    Token Approval Tests\n      ✓ PNETWORK_ADDRESS can add appoved token address\n      ✓ NON_PNETWORK_ADDRESS cannot add appoved token address\n      ✓ PNETWORK_ADDRESS can remove appoved token address\n      ✓ NON_PNETWORK_ADDRESS cannot remove appoved token address\n    Peg In Tests\n      ✓ Should NOT peg in if token is not supported\n      ✓ Should NOT peg in if token is supported but insufficient allowance approved\n      ✓ Should NOT peg in supported token if sufficient allowance approved, but token amount is 0\n      ✓ Should peg in if token is supported and sufficient allowance approved (54ms)\n      ✓ Should peg in with user data (47ms)\n    ERC777 Peg In Tests\n      ✓ Should automatically peg in on ERC777 send (41ms)\n      ✓ Should peg in an ERC777 token\n    Peg Out Tests\n      ✓ NON_PNETWORK_ADDRESS cannot peg out (45ms)\n      ✓ PNETWORK_ADDRESS cannot peg out if insufficient balance\n      ✓ PNETWORK_ADDRESS can peg out with sufficient balance (61ms)\n      ✓ Can peg out with user data (70ms)\n      ✓ Pegging out to ERC777 recipient with user data will call tokens recieved hook (91ms)\n    wETH Tests\n      Peg In wETH Tests\n        ✓ Should peg in wETH\n        ✓ Should peg in wETH with user data\n      Peg Out wETH Tests\n        ✓ Should peg out wETH without user data\n        ✓ Should peg out wETH with user data\n        ✓ Should peg out wETH to smart-contract w/ expensive fallback function (56ms)\n        ✓ Should be able to peg out wETH with user data to a smart-contract (69ms)\n        ✓ Should not fail to peg out wETH with user data to an EOA\n        ✓ Pegging out wETH Should not be susceptible to re-entrancy attack (55ms)\n\n\n  28 passing (8s)\n\n```\n\n\u0026nbsp;\n\n## :white_medium_square: To Do:\n\n[ ] Allow custom gas prices in CLI?\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprovable-things%2Fptokens-erc20-vault","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprovable-things%2Fptokens-erc20-vault","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprovable-things%2Fptokens-erc20-vault/lists"}