Hi I am following this tutorial and I want to create it without the front-end. Only in JS without Metamask interaction. Is that possible?
I would like to use provider and address with ethers and private keys stored in my .env
This is how my code looks like now
import { DIDSession } from "@glazed/did-session";
//import Web3 from "web3";
import { ethers } from "ethers";
import { EthereumWebAuth, getAccountId } from "@didtools/pkh-ethereum";
import { EthereumAuthProvider } from "@ceramicnetwork/blockchain-utils-linking";
import { config } from "dotenv";
config({ path: "/Users/andy/Keys/generalKeys.env" }).parsed;
async function authenticate() {
const ethereumProvider = new ethers.providers.JsonRpcProvider(
String(process.env.URL_MUMBAI)
);
const account = new ethers.Wallet(
process.env.GOVERNOR_PRIVATE_KEY,
ethereumProvider
);
const authProvider = new EthereumAuthProvider(ethereumProvider, account);
console.log(authProvider);
const session = new DIDSession({ authProvider });
console.log(session);
const did = await session.authorize();
// ceramic.did = did;
}
await authenticate();
And this is how my authProvider object looks now
EthereumAuthProvider {
provider: JsonRpcProvider {
_isProvider: true,
_events: [],
_emitted: { block: -2 },
disableCcipRead: false,
formatter: Formatter { formats: [Object] },
anyNetwork: false,
_networkPromise: Promise { <pending> },
_maxInternalBlockNumber: -1024,
_lastBlockNumber: -2,
_maxFilterBlockRange: 10,
_pollingInterval: 4000,
_fastQueryDate: 0,
connection: {
url: 'https://polygon-mumbai.infura.io/v3/....'
},
_nextId: 42
},
address: Wallet {
_isSigner: true,
_signingKey: [Function (anonymous)],
_mnemonic: [Function (anonymous)],
address: '0xda97f787dd561C1115ba5E95B80CfAb3f7Dd7001',
provider: JsonRpcProvider {
_isProvider: true,
_events: [],
_emitted: [Object],
disableCcipRead: false,
formatter: [Formatter],
anyNetwork: false,
_networkPromise: [Promise],
_maxInternalBlockNumber: -1024,
_lastBlockNumber: -2,
_maxFilterBlockRange: 10,
_pollingInterval: 4000,
_fastQueryDate: 0,
connection: [Object],
_nextId: 42
}
},
opts: {},
isAuthProvider: true
}
And this is the error I get
Error: Missing parameter 'domain'
at EthereumAuthProvider.requestCapability (file:///Users/andy/my_repos/Tutorials/Ceramic/node_modules/@ceramicnetwork/blockchain-utils-linking/lib/ethereum.js:52:19)
at DIDSession.authorize (file:///Users/andy/my_repos/Tutorials/Ceramic/node_modules/@glazed/did-session/dist/index.js:209:94)
at async authenticateWithEthereum (file:///Users/andy/my_repos/Tutorials/Ceramic/did-sessions.js:28:15)
at async file:///Users/andy/my_repos/Tutorials/Ceramic/did-sessions.js:33:1