How to use the web3-eth-abi.encodeParameters function in web3-eth-abi

To help you get started, we’ve selected a few web3-eth-abi 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 jpmorganchase / anonymous-zether / packages / anonymous.js / src / prover / innerproduct.js View on Github external
var bsRight = bs.slice(nPrime);
            var gLeft = base.getGs().slice(0, nPrime);
            var gRight = base.getGs().slice(nPrime);
            var hLeft = base.getHs().slice(0, nPrime);
            var hRight = base.getHs().slice(nPrime);

            var cL = asLeft.innerProduct(bsRight);
            var cR = asRight.innerProduct(bsLeft);

            var u = base.getH();
            var L = gRight.commit(asLeft).add(hLeft.commit(bsRight)).add(u.mul(cL));
            var R = gLeft.commit(asRight).add(hRight.commit(bsLeft)).add(u.mul(cR));
            ls.push(L);
            rs.push(R);

            var x = utils.hash(ABICoder.encodeParameters(['bytes32', 'bytes32[2]', 'bytes32[2]'], [bn128.bytes(previousChallenge), bn128.serialize(L), bn128.serialize(R)]));
            var xInv = x.redInvm();
            var gPrime = gLeft.times(xInv).add(gRight.times(x));
            var hPrime = hLeft.times(x).add(hRight.times(xInv));
            var aPrime = asLeft.times(x).add(asRight.times(xInv));
            var bPrime = bsLeft.times(xInv).add(bsRight.times(x));

            var PPrime = L.mul(x.redMul(x)).add(R.mul(xInv.redMul(xInv))).add(P);
            var basePrime = new GeneratorParams(u, gPrime, hPrime);

            return generateProof(basePrime, PPrime, aPrime, bPrime, ls, rs, x);
        };
github merklejerk / flex-contract / src / coder.js View on Github external
function encodeConstructorCall(bytecode, def, args=[]) {
	return util.addHexPrefix(bytecode) +
		util.stripHexPrefix(abiEncoder.encodeParameters(
			def.inputs,
			normalizeEncodeInput(def.inputs, args),
		));
}
github AztecProtocol / AZTEC / packages / aztec.js / src / proof / proofs / UTILITY / epoch0 / publicRange / index.js View on Github external
constructOutputs() {
        const proofOutput = {
            inputNotes: this.inputNotes,
            outputNotes: this.outputNotes,
            publicValue: this.publicValue,
            publicOwner: this.publicOwner,
            challenge: this.challengeHex,
        };
        this.output = outputCoder.encodeProofOutput(proofOutput);
        this.outputs = outputCoder.encodeProofOutputs([proofOutput]);
        this.hash = outputCoder.hashProofOutput(this.output);
        this.validatedProofHash = keccak256(
            AbiCoder.encodeParameters(['bytes32', 'uint24', 'address'], [this.hash, proofs.PUBLIC_RANGE_PROOF, this.sender]),
        );
    }
github AztecProtocol / AZTEC / packages / aztec.js / src / proof / joinSplit / index.js View on Github external
constructOutputs() {
        const proofOutput = {
            inputNotes: this.inputNotes,
            outputNotes: this.outputNotes,
            publicValue: this.publicValue,
            publicOwner: this.publicOwner,
            challenge: this.challengeHex,
        };
        this.output = outputCoder.encodeProofOutput(proofOutput);
        this.outputs = outputCoder.encodeProofOutputs([proofOutput]);
        this.hash = outputCoder.hashProofOutput(this.output);
        this.validatedProofHash = keccak256(
            AbiCoder.encodeParameters(['bytes32', 'uint24', 'address'], [this.hash, proofs.JOIN_SPLIT_PROOF, this.sender]),
        );
    }
github mosaicdao / mosaic.js / src / utils / EIP712SignerExtension / TypedData.js View on Github external
encTypes.push('bytes32');
        value = Web3Utils.keccak256(value);
        encValues.push(value);
      } else if (types[field.type] !== undefined) {
        encTypes.push('bytes32');
        value = Web3Utils.keccak256(oThis.encodeData(field.type, value));
        encValues.push(value);
      } else if (field.type.lastIndexOf(']') === field.type.length - 1) {
        throw 'Arrays currently unimplemented in encodeData';
      } else {
        encTypes.push(field.type);
        encValues.push(value);
      }
    }

    return Web3Abi.encodeParameters(encTypes, encValues);
  }
github breadwallet / smart-contracts / scripts / deploy.js View on Github external
function encodeConstructorArgs(types, args) {
    return abi.encodeParameters(types, args).substring(2);
}
github fidenz-chim / web3js-raw / index.js View on Github external
this.encodeFunctionParams = function(abi,methodName, params){
        var types = this.getFunctionParams(abi,methodName);
        var fullName = methodName +  '(' + types.join() + ')';
        var signature = CryptoJS.SHA3(fullName,{outputLength:256}).toString(CryptoJS.enc.Hex).slice(0, 8);
        var dataHex = signature  + Web3EthAbi.encodeParameters(...types, params).substring(2);

        var payload = '0x'+dataHex;

        return payload;
    }
github AztecProtocol / AZTEC / packages / aztec.js / src / proof / proofs / BALANCED / epoch0 / swap / index.js View on Github external
outputNotes: [this.outputNotes[0]],
                publicValue: this.publicValue,
                publicOwner: this.publicOwner,
                challenge: this.challengeHex,
            },
            {
                inputNotes: [this.outputNotes[1]],
                outputNotes: [this.inputNotes[1]],
                publicValue: this.publicValue,
                publicOwner: this.publicOwner,
                challenge: `0x${keccak256(this.challengeHex).slice(2)}`,
            },
        ]);
        this.hash = outputCoder.hashProofOutput(this.outputs);
        this.validatedProofHash = keccak256(
            AbiCoder.encodeParameters(['bytes32', 'uint24', 'address'], [this.hash, proofs.SWAP_PROOF, this.sender]),
        );
    }
github AztecProtocol / AZTEC / packages / aztec.js / src / proof / swap / index.js View on Github external
outputNotes: [this.outputNotes[0]],
                publicValue: this.publicValue,
                publicOwner: this.publicOwner,
                challenge: this.challengeHex,
            },
            {
                inputNotes: [this.outputNotes[1]],
                outputNotes: [this.inputNotes[1]],
                publicValue: this.publicValue,
                publicOwner: this.publicOwner,
                challenge: `0x${keccak256(this.challengeHex).slice(2)}`,
            },
        ]);
        this.hash = outputCoder.hashProofOutput(this.outputs);
        this.validatedProofHash = keccak256(
            AbiCoder.encodeParameters(['bytes32', 'uint24', 'address'], [this.hash, proofs.SWAP_PROOF, this.sender]),
        );
    }