How do I force set the user context without a key value store or wallet?

226 Views Asked by At

For testing purposes, I already have the public key + private key + certificate on hand (can just hardcode it), and I can set up the CA through the connection profile, but how would I invoke a transaction without setting up the filesystem key value store/wallet?

1

There are 1 best solutions below

0
On BEST ANSWER

Use the InMemoryWallet class - see https://fabric-sdk-node.github.io/master/module-fabric-network.InMemoryWallet.html

example:

 const credPath = '/home/demo/mynetwork/crypto-material/crypto-config/peerOrganizations/org1.example.com/users/[email protected]/msp';
 const cert = fs.readFileSync(credPath + '/cert.pem').toString();
 const key = fs.readFileSync(credPath + '/key.pem').toString();
 const inMemoryWallet = new InMemoryWallet();
 await inMemoryWallet.import('admin', X509WalletMixin.createIdentity('Org1MSP', cert, key));

or check out the integration test scripts for Fabric Node SDK