How to use the fabric-shim.ClientIdentity function in fabric-shim

To help you get started, we’ve selected a few fabric-shim examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github IBM / decentralized-energy-fabric-on-IBP20 / contract / lib / my-contract.js View on Github external
async CashTrade(ctx, cashRate, cashValue, cashReceiverId, cashSenderId) {
        var cid = new ClientIdentity(ctx.stub);
        console.info(`Received "CashTrade" transaction from ${cid.getID()}`);
        var coinsValue = Number(cashRate) * Number(cashValue);

        // first check: tx invoker can only send from his account
        const senderData = await ctx.stub.getState(cashSenderId);
        if (!senderData) {
            throw new Error('Sender does not exist, create participant first');
        }

        const receiverData = await ctx.stub.getState(cashReceiverId);
        if (!receiverData) {
            throw new Error('Receiver does not exist, create participant first');
        }
        // console.log(JSON.parse(senderData))
        var sender = JSON.parse(senderData);
        var receiver = JSON.parse(receiverData);
github hyperledger / fabric-chaincode-node / test / chaincodes / clientidentity / chaincode.js View on Github external
async clientIdentityInstance({stub}) {
        const cid = new shim.ClientIdentity(stub);
        return {mspId: cid.mspId, id: cid.id};
    }
github hyperledger / fabric-chaincode-node / test / typescript / chaincode.ts View on Github external
testClientIdentity(stub: ChaincodeStub): void {
        const cID = new ClientIdentity(stub);
        const name = 'mockName';
        const value = 'mockValue';
        const attributeValue: string | null = cID.getAttributeValue(name);
        const id: string = cID.getID();
        const mspid: string = cID.getMSPID();
        const newAttributeValue: boolean = cID.assertAttributeValue(name, value);
        const X509Certificate: X509.Certificate = cID.getX509Certificate();
        this.testCert(X509Certificate);
    }
github IBM / decentralized-energy-fabric-on-IBP20 / contract / lib / my-contract.js View on Github external
async AddUtilityCompany(ctx, utilityCompanyId, name, coinsBalance, energyValue, energyUnits) {
        var cid = new ClientIdentity(ctx.stub);
        console.info(`Received "AddUtilityCompany" transaction from ${cid.getID()}`);
        var coins = {
            "value": Number(coinsBalance)
        };

        var energy = {
            "value": Number(energyValue),
            "units": energyUnits
        };

        var utilityCompany = {
            "participantId": cid.getID(),
            "utilityCompanyId": utilityCompanyId,
            "name": name,
            "coins": coins,
            "energy": energy,
github xcottos / convector-example-supplychain-master / chaincode-supplychainchaincode / chaincode.js View on Github external
return tslib_1.__generator(this, function (_a) {
                                            identity = new fabric_shim_1.ClientIdentity(stubHelper.getStub());
                                            fingerprint = identity.getX509Certificate().fingerPrint;
                                            return [2, obj[fnName].call(this, stubHelper, _args, {
                                                    sender: {
                                                        value: fingerprint
                                                    },
                                                    tx: {
                                                        value: new chaincode_tx_1.ChaincodeTx(stubHelper, identity)
                                                    }
                                                })];
                                        });
                                    }); } : obj[fnName], _b)));
github hyperledger-labs / convector / @worldsibu / convector-core-chaincode / src / chaincode.ts View on Github external
async (stubHelper: StubHelper, _args: string[]) => {
              const identity = new ClientIdentity(stubHelper.getStub());
              const fingerprint = identity.getX509Certificate().fingerPrint;
              return obj[fnName].call(this, stubHelper, _args, {
                sender: {
                  value: fingerprint
                },
                tx: {
                  value: new ChaincodeTx(stubHelper, identity)
                }
              });
            } : obj[fnName]
        }), { [ctrlInvokables.namespace]: obj });
github instamed / healthcare-payments-blockchain / packages / participant-cc / src / participant.controller.ts View on Github external
get fullIdentity(): ClientIdentity {
    const stub = (BaseStorage.current as any).stubHelper;
    return new ClientIdentity(stub.getStub());
  };
github worldsibu / convector-identity-patterns / packages / participant-cc / dist / src / participant.controller.js View on Github external
get: function () {
            var stub = convector_core_storage_1.BaseStorage.current.stubHelper;
            return new fabric_shim_1.ClientIdentity(stub.getStub());
        },
        enumerable: true,