{"id":26464769,"url":"https://github.com/coming-chat/wallet-sdk","last_synced_at":"2025-03-19T08:48:47.537Z","repository":{"id":37662330,"uuid":"436133188","full_name":"coming-chat/wallet-SDK","owner":"coming-chat","description":"One-stop omnichain sdk that integrates bitcoin, evm blockchain (ethereum/bsc/polygon/avax/...), aptos, sui, polkadot, cosmos, solana, doge, etc.","archived":false,"fork":false,"pushed_at":"2024-04-14T16:05:24.000Z","size":1555,"stargazers_count":103,"open_issues_count":3,"forks_count":33,"subscribers_count":11,"default_branch":"main","last_synced_at":"2024-04-14T16:15:53.236Z","etag":null,"topics":["aptos","blockchain","bsc","btc","ethereum","golang","polkadot","sui","wallet"],"latest_commit_sha":null,"homepage":"https://coming.chat/","language":"Go","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/coming-chat.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,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2021-12-08T05:55:30.000Z","updated_at":"2024-04-16T10:53:49.450Z","dependencies_parsed_at":"2024-01-08T05:37:04.287Z","dependency_job_id":"a216fe78-5882-4371-b008-15d2404ea8bf","html_url":"https://github.com/coming-chat/wallet-SDK","commit_stats":null,"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coming-chat%2Fwallet-SDK","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coming-chat%2Fwallet-SDK/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coming-chat%2Fwallet-SDK/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coming-chat%2Fwallet-SDK/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/coming-chat","download_url":"https://codeload.github.com/coming-chat/wallet-SDK/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244394470,"owners_count":20445634,"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":["aptos","blockchain","bsc","btc","ethereum","golang","polkadot","sui","wallet"],"created_at":"2025-03-19T08:48:46.760Z","updated_at":"2025-03-19T08:48:47.529Z","avatar_url":"https://github.com/coming-chat.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# wallet-SDK\n\n|                       | Bitcoin | Ethereum | Polka | Cosmos | Doge | Solana | Aptos | Sui | Starcoin | Starknet |\n| --------------------- | ------- | -------- | ----- | ------ | ------ | ------ | ------ | ------ | ------ | ------ |\n| import mnemonic       | ✅     | ✅      | ✅   |✅   |✅   |✅   |✅   |✅   |✅   |✅   |\n| import keystore       | ❌     | ❌      | ✅  |❌   |❌   |❌   |❌   |❌   |❌   |❌   |\n| pri/pub key \u0026 address | ✅     | ✅      | ✅   |✅   |✅   |✅   |✅   |✅   |✅   |✅   |\n| multi network         | ✅     | ✅      | ✅   |✅   |❌   |✅   |✅   |✅   |✅   |✅   |\n| publicKey to address  | ✅     | ✅      | ✅   |✅   |✅   |✅   |✅   |✅   |✅   |✅   |\n| address to publicKey  | ❌     | ❌      | ✅   |❌   |❌   |✅   |❌   |❌   |❌   |❌   |\n| sign data             | ☑️    | ✅    | ✅   |☑️   |☑️   |☑️   |✅   |✅   |✅   |❌   |\n|                       |         |          |       |        |      |        |        |        |        |        |\n| query balance | ✅ | ✅ | ✅ |✅   |✅   |✅   |✅   |✅   | ✅ | ✅ |\n| fetch transaction detail | ✅ | ✅ | ✅ |✅   |✅   |✅   |✅   |✅   | ✅ | ✅ |\n| gas fee | ❌ | ✅ | ✅ |☑️   |✅   |✅   |✅   |❌   | ✅ | ✅ |\n| send raw transaction | ✅ | ✅ | ✅ ☑️ |✅   |✅   |✅   |✅   |✅   | ✅ | ✅ |\n| multi token | ❌ | ✅ erc20 | ✅ XBTC |✅   |❌   |❌   |✅   |❌   | ❌ | ✅ |\n\n*If there are two icons, the first icon indicates development status, and the second icon indicates test status.*\n✅: Completed      ☑️: TODO    ❌: Unsupported\n\n## Usage\n\n### About Wallet \n\nSDK provide wallet import, account public and private key and address acquisition.\n\n#### Import Wallet\n\n```golang\n// import mnemonic\nwallet, err = NewWalletFromMnemonic(mnemonic)\n\n// import keystore\n// It only supports Polka keystore.\nwallet, err = NewWalletFromKeyStore(keyStoreJson, password)\n```\n\n#### Create Account\n\nWe currently support accounts in Bitcoin, Ethereum and Polkadot ecosystems.\n\n```golang\n// Polka\npolkaAccount, err = wallet.GetOrCreatePolkaAccount(network)\n\n// Bitcoin\nbitcoinAccount, err = wallet.GetOrCreateBitcoinAccount(chainnet)\n\n// Ethereum\nethereumAccount, err = wallet.GetOrCreateEthereumAccount()\n\n// Cosmos\ncosmosAccount, err = wallet.GetOrCreateCosmosAccount()\n\n// Terra is a type of cosmos\nterraAccount, err = wallet.GetOrCreateCosmosTypeAccount(330, \"terra\")\n```\n\n#### Get PrivateKey, PublicKey, Address\n\n```golang\nprivateData, err = account.PrivateKeyData()\n\nprivateKey, err = account.PrivateKey()\n\npublicKey = account.PublicKey()\n\naddress = account.Address()\n```\n\n\n### About Chain\n\nWe can use chain tools to do chain related work.\n* query balance\n* query estimate fees\n* send transaction\n* fetch transaction detail\n* support multi token: \n  * eth contract erc20 token\n  * xbtc\n\n#### Create Chain\n\n```go\npolkaChain, err = polka.NewChainWithRpc(rpcUrl, scanUrl, network)\n\nbitcoinChain, err = btc.NewChainWithChainnet(chainnet)\n\nethereumChain, err = eth.NewChainWithRpc(rpcUrl)\n\ncosmosChain, err = cosmos.NewChainWithRpc(rpcUrl, restUrl)\nterraChain, err = cosmos.NewChainWithRpc(terraRpcUrl, terraRestUrl)\n```\n\n#### Methods\n\n```golang \n\n// query balance\nbalance, err = chain.BalanceOfAddress(address)\nbalance, err = chain.BalanceOfPublicKey(publicKey)\nbalance, err = chain.BalanceOfAccount(account)\n\n// send transaction\ntxHash, err = chain.SendRawTransaction(signedTx)\n\n// fetch transaction detail\ndetail, err = chain.FetchTransactionDetail(hashString)\nstatus = chain.FetchTransactionStatus(hashString)\n```\n\n#### Chain's Token\n\n```golang\n// MainToken\ntoken = chain.MainToken()\n\n// btc have not tokens\n\n// polka (only support XBTC of ChainX currently)\nxbtcToken = polkaChain.XBTCToken()\n\n// ethereum erc20 token\nerc20Token = ethereumChain.Erc20Token(contractAddress)\n\n// cosmos token\natomToken = cosmosChain.DenomToken(\"cosmos\", \"uatom\")\nustToken = terraChain.DenomToken(\"terra\", \"uusd\")\n\n// token balance (similar to chain's balance)\nbalance, err = anyToken.BalanceOfAddress(address)\nbalance, err = anyToken.BalanceOfPublicKey(publicKey)\nbalance, err = anyToken.BalanceOfAccount(account)\n```\n\n#### Estimate fee\n\n```golang\n// sbtc's estimate fee is compute by utxo\n\n// polka \ntransaction = // ...\nfee, err = polkaChain.EstimateFeeForTransaction(transaction)\n\n// ethereum\ngasPrice, err = ethChain.SuggestGasPrice()\ngasLimit, err = anyEthToken.EstimateGasLimit(fromAddress, receiverAddress, gasPrice, amount)\n```\n\n--------------------------------------------------------------------------------\n--------------------------------------------------------------------------------\n\n\n\n## Cosmos \u0026 Terra Demo\n\n### Creator\n\n```go\n// Import mnemonic\nwallet, err = NewWalletFromMnemonic(mnemonic)\n\n// Cosmos account\ncosmosAccount, err = wallet.GetOrCreateCosmosAccount()\n// Terra is a type of cosmos\nterraAccount, err = wallet.GetOrCreateCosmosTypeAccount(330, \"terra\")\n\n// Create Chain\nchain, err = cosmos.NewChainWithRpc(rpcUrl, restUrl)\n\n// Create a coin token\natomToken = cosmosChain.DenomToken(\"cosmos\", \"uatom\")\nlunaToken = terraChain.DenomToken(\"terra\", \"uluna\")\nustToken = terraChain.DenomToken(\"terra\", \"uusd\")\n```\n\n### Query balance\n\n```go\n// query balance with token\natomBalance, err = atomToken.BalanceOfAddress(\"cosmos1lkw6n8efpj7mk29yvajpn9zue099l359cgzf0t\")\nlunaBalance, err = lunaToken.BalanceOfAddress(\"terra1ncjg4a59x2pgvqy9qjyqprlj8lrwshm0wleht5\")\nustBalance , err =  ustToken.BalanceOfAddress(\"terra1dr7ackrxsqwmac2arx26gre6rj6q3sv29fnn7k\")\n\n// you can query balance with chain directly\natomBalance, err = cosmosChain.BalanceOfAddressAndDenom(\"cosmos1lkw6n8efpj7mk29yvajpn9zue099l359cgzf0t\", \"uatom\") // uatom\nlunaBalance, err =  terraChain.BalanceOfAddressAndDenom(\"terra1ncjg4a59x2pgvqy9qjyqprlj8lrwshm0wleht5\", \"uluna\")  // uluna\nustBalance , err =  terraChain.BalanceOfAddressAndDenom(\"terra1dr7ackrxsqwmac2arx26gre6rj6q3sv29fnn7k\", \"uusd\")   // uusd\n```\n\n### Fetch Transaction Detail\n\n```go\natomDetail, err = cosmosChain.FetchTransactionDetail(\"F068275DE4A4CC904D3E6A412A50DFACC235C62770BCD001E54E00BC4C17B1F0\")\n\nlunaDetail, err =  terraChain.FetchTransactionDetail(\"19771A22934641DBD3D347DCCAE939DAC37F39ABD88005AA735B8AAEA78599BA\")\n\n// exactly the same as luna detail.\nustDetail , err =  terraChain.FetchTransactionDetail(\"25ACF16526D3A4DEE5FE7C5CCEB597B5691134647829AD30CA1E36EDBEAC32B6\")\n```\n\n### Sign \u0026 Send transaction\n\n```go\ncosmosAccount = // create a cosmos account\ntoAddress = \"cosmos1lkw6n8efpj7mk29yvajp......\"\namount = \"100000\"\ngasPrice = \"0.01\"\ngasLimit = \"80000\"\n\nchain = cosmos.NewChainWithRpc(rpcUrl, restUrl)\ntoken = chain.DenomToken(prefix, denom)\n\nsignedTx, err = token.BuildTransferTx(account.PrivateKeyHex(), toAddress, gasPrice, gasLimit, amount)\n\ntxHash, err = chain.SendRawTransaction(signedTx)\n\n```\n\n--------------------------------------------------------------------------------\n--------------------------------------------------------------------------------\n\n\n\n## Ethereum Sign Transaction\n\n```go\nethereumChain, err = eth.NewChainWithRpc(rpcUrl)\n\n// make an transaction object\ntransaction = NewTransaction(nonce, gasPrice, gasLimit, to, value, data)\n// transaction.MaxPriorityFeePerGas = \"10000\" // if send EIP1559 tx\n\n// sign with hexed privatekey\nsignedTxObj, err = ethereumChain.SignTransaction(privateKeyHex, transaction)\n// sign with ethereum account\nsignedTxObj, err = ethereumChain.SignTransactionWithAccount(ethAccount, transaction) \n\nsignedHashString = signedTxObj.Value // signed transaction hash string\n```\n\n--------------------------------------------------------------------------------\n--------------------------------------------------------------------------------\n\n### Decide Merge \u0026 Split Coin\n\n```golang\n// If you get any error, example\nvar transaction, err = chain.AddDelegation(owner, amount, validator)\nif err != nil {\n  if IsMergeError(err) {\n    // You need merge coins\n  }\n  if IsSplitError(err) {\n    // You need split coin\n  }\n}\n```\n\n### Sui Merge Coin\n\n```golang\nvar owner = \"0x123abc\"\nvar coinType = \"0x2::sui::SUI\" // Default\nvar targetAmount = (10,000,000,000).toString() // 10 SUI\n\n// make request\nvar mergeRequest = chain.BuildMergeCoinRequest(owner, coinType, targetAmount)\nprintln(mergeRequest.WillBeAchieved)\nprintln(mergeRequest.EstimateAmount)\nprintln(\"merging coin count = \", mergeRequest.CoinsCount)\n\n// preview merge result\nvar mergePreview = chain.BuildMergeCoinPreview(mergeRequest)\nprintln(mergePreview.SimulateSuccess)\nprintln(mergePreview.EstimateGasFee)\nprintln(mergePreview.WillBeAchieved)\nprintln(mergePreview.EstimateAmount)\n\n// sign \u0026 send\nvar txn = mergePreview.Transaction\nvar account = ...\nvar signedTxn = txn.SignWithAccount(account)\nvar hash = chain.SendRawTransaction(signedTxn)\n```\n\n### Sui Split Coin\n\n```golang\n// build transaction\nvar transaction = chain.BuildSplitCoinTransaction(owner, coinType, targetAmount)\n\n// estimate gas fee\nvar estimateFee = chain.EstimateGasFee(transaction)\n\n// sign \u0026 send\n......\n```\n\n\n--------------------------------------------------------------------------------\n--------------------------------------------------------------------------------\n\n\n\nComingChat substrate wallet SDK\n\n## Build Android \u0026\u0026 Ios\n\n* make buildAllAndroid\n* make buildAllIOS\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoming-chat%2Fwallet-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoming-chat%2Fwallet-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoming-chat%2Fwallet-sdk/lists"}