{"id":18953116,"url":"https://github.com/0xpolygon/maticjs-fxportal","last_synced_at":"2025-04-16T02:31:50.898Z","repository":{"id":45116839,"uuid":"399352244","full_name":"0xPolygon/maticjs-fxportal","owner":"0xPolygon","description":"Library for interacting with fx-portal bridge.","archived":false,"fork":false,"pushed_at":"2022-12-11T01:20:41.000Z","size":1138,"stargazers_count":23,"open_issues_count":3,"forks_count":8,"subscribers_count":7,"default_branch":"main","last_synced_at":"2024-11-01T12:05:43.842Z","etag":null,"topics":["fxportal","matic","polygon"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/0xPolygon.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-08-24T05:59:25.000Z","updated_at":"2024-10-08T21:52:45.000Z","dependencies_parsed_at":"2023-01-26T13:31:57.349Z","dependency_job_id":null,"html_url":"https://github.com/0xPolygon/maticjs-fxportal","commit_stats":null,"previous_names":["fx-portal/maticjs-fxportal"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xPolygon%2Fmaticjs-fxportal","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xPolygon%2Fmaticjs-fxportal/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xPolygon%2Fmaticjs-fxportal/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xPolygon%2Fmaticjs-fxportal/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/0xPolygon","download_url":"https://codeload.github.com/0xPolygon/maticjs-fxportal/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223692691,"owners_count":17187061,"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":["fxportal","matic","polygon"],"created_at":"2024-11-08T13:36:25.784Z","updated_at":"2024-11-08T13:36:26.433Z","avatar_url":"https://github.com/0xPolygon.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![TEST](https://github.com/fx-portal/maticjs-fxportal/actions/workflows/test.yml/badge.svg)](https://github.com/fx-portal/maticjs-fxportal/actions/workflows/test.yml)\n[![npm version](https://badge.fury.io/js/@fxportal%2Fmaticjs-fxportal.svg)](https://badge.fury.io/js/@fxportal%2Fmaticjs-fxportal)\n# maticjs-fxportal\n\nFxPortal bridge plugin for maticjs. It provides FxPortalClient to interact with fxportal bridge.\n\n# Installation\n\n```\nnpm i @fxportal/maticjs-fxportal\n```\n\n## Install ethers library\n\nCurrently `matic.js` support two ethers library - \n\n### 1. web3.js\n\n```\nnpm i @maticnetwork/maticjs-web3\n```\n\n### 2. Ethers\n\n```\nnpm i @maticnetwork/maticjs-ethers\n```\n\n# DOCS\n\n## Initiate client\n\n```\nconst { use } = require(\"@maticnetwork/maticjs\");\nconst { Web3ClientPlugin } = require(\"@maticnetwork/maticjs-web3\");\nconst { FxPortalClient } = require(\"@fxportal/maticjs-fxportal\");\n\nconst HDWalletProvider = require(\"@truffle/hdwallet-provider\");\n\n// add Web3Plugin\n\nuse(Web3ClientPlugin);\n\nconst fxPortalClient = new FxPortalClient();\n\nawait fxPortalClient.init({\n    network: 'testnet',\n    version: 'mumbai',\n    parent: {\n        provider: new HDWalletProvider(privateKey, rootRPC),\n        defaultConfig: {\n            from\n        }\n    },\n    child: {\n        provider: new HDWalletProvider(privateKey, childRPC),\n        defaultConfig: {\n            from\n        }\n    }\n});\n\n```\n\n## ERC20\n\nMethod `erc20` allows you to interact with erc20 token.\n\n```\nconst erc20 = fxPortalClient.erc20(\u003ctokenAddress\u003e, \u003cisRoot\u003e);\n```\n\n### getBalance\n\nGet balance of a user by supplying user address\n\n```\nconst balance = await erc20.getBalance(\u003cuser address\u003e);\n```\n### getName\n\nGet name of token\n\n```\nconst name = await erc20.getName();\n```\n### getDecimals\n\nGet decimals of token\n\n```\nconst decimals = await erc20.getDecimals();\n```\n### getSymbol\n\nGet symbol of token\n\n```\nconst decimals = await erc20.getSymbol();\n```\n\n### approve\n\nApprove required amount for depositing to polygon chain\n\n```\nconst approveResult = await erc20.approve(\u003camount\u003e);\nconst txHash = await approveResult.getTransactionHash();\nconst receipt = await approveResult.getReceipt();\n```\n\n### approveMax\n\nApprove max amount for depositing to polygon chain\n\n```\nconst approveResult = await erc20.approveMax();\nconst txHash = await approveResult.getTransactionHash();\nconst receipt = await approveResult.getReceipt();\n```\n\n### getAllowance\n\nGet approve amount of a user by supplying user address\n\n```\nconst balance = await erc20.getAllowance(\u003cuser address\u003e);\n```\n\n### deposit\n\nDeposit required amount from ethereum to polygon\n\n```\nconst result = await erc20.deposit(\u003camount\u003e, \u003cuser address\u003e);\nconst txHash = await result.getTransactionHash();\nconst receipt = await result.getReceipt();\n```\n\n### withdrawStart\n\nInitiate withdraw process by burning the required amount. \n\n```\nconst result = await erc20.withdrawStart(\u003camount\u003e);\nconst txHash = await result.getTransactionHash();\nconst receipt = await result.getReceipt();\n```\n### withdrawToStart\n\nInitiate withdrawTo process by burning the required amount. \n\n```\nconst result = await erc20.withdrawToStart(\u003camount\u003e, \u003cto address\u003e);\nconst txHash = await result.getTransactionHash();\nconst receipt = await result.getReceipt();\n```\n### withdrawExit\n\nExit withdraw process by providng txHash received in `withdrawStart` process.\n\n**Note:-** `withdrawExit` can be called after checkpoint has been submitted for `withdrawStart`.\n\n```\nconst result = await erc20.withdrawExit(\u003cburn tx hash\u003e);\nconst txHash = await result.getTransactionHash();\nconst receipt = await result.getReceipt();\n```\n### withdrawExitFaster\n\nFaster exit withdraw process by providng txHash received in `withdrawStart` process.\n\n\u003e It is faster because it uses api to create the proof.\n\n```\nconst result = await erc20.withdrawExitFaster(\u003cburn tx hash\u003e);\nconst txHash = await result.getTransactionHash();\nconst receipt = await result.getReceipt();\n```\n\n## isCheckPointed\n\nCheck if transaction has been checkpointed or not.\n\n```\nawait fxPortalClient.isCheckPointed(\u003ctx hash\u003e);\n```\n\n\n## isWithdrawExited\n\nCheck if withdraw process has been completed by supplying burn transaction hash.\n\n```\nconst balance = await erc20.isExited(\u003cburn tx hash\u003e);\n```\n\n\n## isDeposited\n\nCheck if deposit is completed.\n\n```\nconst balance = await erc20.isDeposited(\u003ctx hash\u003e);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F0xpolygon%2Fmaticjs-fxportal","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F0xpolygon%2Fmaticjs-fxportal","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F0xpolygon%2Fmaticjs-fxportal/lists"}