Created
January 6, 2023 22:13
-
-
Save trgarrett/60be47d13305139b890b793fb5afdc23 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component } from '@angular/core'; | |
import SignClient from "@walletconnect/sign-client"; | |
import { Web3Modal } from "@web3modal/standalone"; | |
@Component({ | |
selector: 'walletconnect', | |
templateUrl: './walletconnect.component.html', | |
styleUrls: ['./walletconnect.component.css'] | |
}) | |
export class WalletConnectComponent { | |
constructor() { | |
} | |
async onConnect() { | |
const projectId = "xxxxxxxxxx"; // CHANGE: you need your own by registering at WalletConnect.com | |
const web3Modal = new Web3Modal({ | |
projectId: projectId, | |
standaloneChains: ["chia:mainnet"], | |
}); | |
const signClient = await SignClient.init({ | |
projectId: projectId, | |
metadata: { | |
name: "splitxch.com", // CHANGE | |
description: "", //CHANGE | |
url: "splitxch.com", //CHANGE | |
icons: ["https://splitxch.com/assets/favicon.png"], //CHANGE | |
} | |
}); | |
const { uri, approval } = await signClient.connect({ | |
requiredNamespaces: { | |
chia: { | |
methods: ["chia_getCurrentAddress"], | |
chains: ["chia:mainnet"], | |
events: [] | |
} | |
}, | |
}); | |
if (uri) { | |
web3Modal.openModal({ | |
uri: uri, | |
standaloneChains: ["chia:mainnet"], | |
route: 'ConnectWallet' | |
}); | |
await approval(); | |
web3Modal.closeModal(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Other things you can ask for:
methods: ["chia_getWalletBalance", "chia_getWallets", "chia_getCurrentAddress", "chia_sendTransaction", "chia_signMessageById", "chia_signMessageByAddress", "chia_getCATAssetId", "chia_spendCAT"],