{"id":13566853,"url":"https://github.com/cosmos/snap","last_synced_at":"2025-04-30T21:07:06.502Z","repository":{"id":172918440,"uuid":"626860226","full_name":"cosmos/snap","owner":"cosmos","description":"Packages That Add Cosmos Support Into Metamask. The Cosmos is Expanding!","archived":false,"fork":false,"pushed_at":"2024-08-28T20:01:15.000Z","size":19304,"stargazers_count":39,"open_issues_count":4,"forks_count":15,"subscribers_count":10,"default_branch":"main","last_synced_at":"2025-04-30T21:06:25.145Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://metamask.mysticlabs.xyz/","language":"TypeScript","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/cosmos.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","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,"publiccode":null,"codemeta":null}},"created_at":"2023-04-12T09:55:50.000Z","updated_at":"2025-04-04T03:57:14.000Z","dependencies_parsed_at":null,"dependency_job_id":"2f397ad5-8254-4367-8c92-b86c124952b5","html_url":"https://github.com/cosmos/snap","commit_stats":null,"previous_names":["cosmos/snap"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cosmos%2Fsnap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cosmos%2Fsnap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cosmos%2Fsnap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cosmos%2Fsnap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cosmos","download_url":"https://codeload.github.com/cosmos/snap/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251782761,"owners_count":21642986,"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":"2024-08-01T13:02:18.068Z","updated_at":"2025-04-30T21:07:06.427Z","avatar_url":"https://github.com/cosmos.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# Cosmos MetaMask Snap\nCosmos Metamask Snap aims to add full support of Metamask, a highly popular Ethereum wallet, to all Cosmos SDK blockchains, potentially opening the door to over 30 million Ethereum users and stimulating growth for every project in the Cosmos ecosystem.\n\n## Developer Preview Software\nPlease note, to develop this Metamask Snap you need to use Metamask Flask, a canary distribution for developers that provides access to upcoming features within Metamask.\n\n## Contribution\nYour contributions are always welcome! Please have a look at the [contribution guidelines](CONTRIBUTING.md) first.\n\n## Running Snap\n```bash\nyarn install\ncd packages/snap\nyarn start\n```\n\n## Running Snap UI\n```bash\nyarn install\ncd packages/ui\nyarn run dev\n```\n\n## Install \u0026 Initialize\n```javascript\n// Check if the Snap is installed\nlet result = await window.ethereum.request({ method: 'wallet_getSnaps' });\nconst installed = Object.keys(result).includes(\"npm:@cosmsnap/snap\");\n\n// Install Snap\nif (!installed) {\n    const result = await window.ethereum.request({\n        method: 'wallet_requestSnaps',\n        params: {\n            'npm:@cosmsnap/snap': {\n            version: '^0.1.0',\n            },\n        },\n    });\n}\n\n// Initialize the Snap with default chains\nawait ethereum.request({\n    method: 'wallet_invokeSnap',\n    params: {\n        snapId: 'npm:@cosmsnap/snap',\n        request: {\n            method: 'initialize',\n        },\n    },\n});\n```\n\n## Check If Initialized\n```javascript\n// Boolean is returned\nconst initialized = await ethereum.request({\n    method: 'wallet_invokeSnap',\n    params: {\n        snapId: 'npm:@cosmsnap/snap',\n        request: {\n            method: 'initialized',\n        },\n    },\n});\n```\n\n## Suggest Chain\nThis Snap has default support for coin types `118, 564, 459, 529, 330, 494, 639, 483, 4444, 701, 990, 394, 852, 7777777, 880, 931, 371, 370, 505, 234, 5555`. All the coin types within the chain registry except for coin type 60 (Ethermint, which is already supported in standard MetaMask). If you need any other please add an issue to the repo [here](https://github.com/cosmos/snap/issues) and we will gladly add it.\n\nChain info is structured like in the chain registry (i.e [Agoric](https://github.com/cosmos/chain-registry/tree/master/agoric))\n```javascript\n// chainInfo should be structured like this https://github.com/cosmos/chain-registry/tree/master/agoric\nawait window.ethereum.request({\n    method: 'wallet_invokeSnap',\n    params: {\n        snapId: 'npm:@cosmsnap/snap',\n        request: {\n            method: 'addChain',\n            params: {\n                chain_info: JSON.stringify(chainInfo),\n            }\n        },\n    },\n});\n```\n\n## Get Chains\n```javascript\nconst chains = await window.ethereum.request({\n    method: 'wallet_invokeSnap',\n    params: {\n        snapId: 'npm:@cosmsnap/snap',\n        request: {\n            method: 'getChains'\n        },\n    },\n});\n```\n\n## Delete Chain\n```javascript\nconst chain = await window.ethereum.request({\n    method: 'wallet_invokeSnap',\n    params: {\n        snapId: 'npm:@cosmsnap/snap',\n        request: {\n            method: 'deleteChain',\n            params: {\n                chain_id: 'cosmoshub-4',\n            }\n        },\n    },\n});\n```\n\n## Send Transaction\n```javascript\nconst msgs = [\n    {\n        typeUrl: \"/cosmos.bank.v1beta1.MsgSend\",\n        value: {\n            fromAddress: senderAddress,\n            toAddress: recipientAddress,\n            amount: [{\n                denom: \"uatom\",\n                amount: \"500000\"\n            }],\n        },\n    }\n];\nconst fees = {\n    amount: [{\n        denom: \"uatom\",\n        amount: \"500\"\n    }],\n    gas: \"200000\"\n};\nconst address = await window.ethereum.request({\n    method: 'wallet_invokeSnap',\n    params: {\n        snapId: 'npm:@cosmsnap/snap',\n        request: {\n            method: 'transact',\n            params: {\n                chain_id: 'cosmoshub-4',\n                msgs: JSON.stringify(msgs),\n                // Optional: Uses default fees for chain if not specified\n                fees: JSON.stringify(fees)\n            }\n        },\n    },\n});\n```\n\n## Sign Transaction\nThis will sign the transaction and return the transaction bytes.\nNOTE: This does not broadcast the transaction.\n```javascript\nconst msgs = [\n    {\n        typeUrl: \"/cosmos.bank.v1beta1.MsgSend\",\n        value: {\n            fromAddress: senderAddress,\n            toAddress: recipientAddress,\n            amount: [{\n                denom: \"uatom\",\n                amount: \"500000\"\n            }],\n        },\n    }\n];\nconst fees = {\n    amount: [{\n        denom: \"uatom\",\n        amount: \"500\"\n    }],\n    gas: \"200000\"\n};\nconst address = await window.ethereum.request({\n    method: 'wallet_invokeSnap',\n    params: {\n        snapId: 'npm:@cosmsnap/snap',\n        request: {\n            method: 'signTx',\n            params: {\n                chain_id: 'cosmoshub-4',\n                msgs: JSON.stringify(msgs),\n                // Optional: Uses default fees for chain if not specified\n                fees: JSON.stringify(fees)\n            }\n        },\n    },\n});\n```\n\n## Add Address (Address Book)\n```javascript\nconst address = await window.ethereum.request({\n    method: 'wallet_invokeSnap',\n    params: {\n        snapId: 'npm:@cosmsnap/snap',\n        request: {\n            method: 'addAddress',\n            params: {\n                chain_id: 'cosmoshub-4',\n                address: 'cosmos123456789',\n                name: 'John Cosmos'\n            }\n        },\n    },\n});\n```\n\n## Get Addresses (Address Book)\n```javascript\nconst address = await window.ethereum.request({\n    method: 'wallet_invokeSnap',\n    params: {\n        snapId: 'npm:@cosmsnap/snap',\n        request: {\n            method: 'getAddresses'\n        },\n    },\n});\n```\n\n## Delete Address (Address Book)\n```javascript\nconst address = await window.ethereum.request({\n    method: 'wallet_invokeSnap',\n    params: {\n        snapId: 'npm:@cosmsnap/snap',\n        request: {\n            method: 'deleteAddress',\n            params: {\n                address: 'cosmos123456789'\n            }\n        },\n    },\n});\n```\n\n## Get Bech32 Address\n```javascript\nconst address = await window.ethereum.request({\n    method: 'wallet_invokeSnap',\n    params: {\n        snapId: 'npm:@cosmsnap/snap',\n        request: {\n            method: 'getChainAddress',\n            params: {\n                chain_id: 'cosmoshub-4',\n            }\n        },\n    },\n});\n```\n\n## Get Bech32 Addresses\n```javascript\nconst address = await window.ethereum.request({\n    method: 'wallet_invokeSnap',\n    params: {\n        snapId: 'npm:@cosmsnap/snap',\n        request: {\n            method: 'getChainAddresses'\n        },\n    },\n});\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcosmos%2Fsnap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcosmos%2Fsnap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcosmos%2Fsnap/lists"}