Skip to content

Instantly share code, notes, and snippets.

@trgarrett
Created January 6, 2023 22:13
Show Gist options
  • Save trgarrett/60be47d13305139b890b793fb5afdc23 to your computer and use it in GitHub Desktop.
Save trgarrett/60be47d13305139b890b793fb5afdc23 to your computer and use it in GitHub Desktop.
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();
}
}
}
@trgarrett
Copy link
Author

Other things you can ask for:
methods: ["chia_getWalletBalance", "chia_getWallets", "chia_getCurrentAddress", "chia_sendTransaction", "chia_signMessageById", "chia_signMessageByAddress", "chia_getCATAssetId", "chia_spendCAT"],

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment