Create a key structure that requires the defined threshold value to sign. A threshold key can contain a Ed25519 or ECDSA (secp256k1_)_ key type. You can use either the public key or the private key to create the key structure. If the threshold requirement is not met when signing transactions, the network will return an "INVALID_SIGNATURE" error.
Constructor
Type
Description
new ThresholdKey(<threshold>)
int
Initializes a ThresholdKey object
newThresholdKey(<threshold>)
Method
Type
Description
add(<key>)
Ed25519PublicKey
Add one public key to the key list
addAll(<keys>)
Ed25519PublicKey
Add all keys to the key list
Java
//Generate 3 keysEd25519PrivateKey key1 =Ed25519PrivateKey.generate();Ed25519PublicKey publicKey1 =key1.publicKey;Ed25519PrivateKey key2 =Ed25519PrivateKey.generate();Ed25519PublicKey publicKey2 =key2.publicKey;Ed25519PrivateKey key3 =Ed25519PrivateKey.generate();Ed25519PublicKey publicKey3 =key3.publicKey;// require 2 of the 3 keys we generated to sign on anything modifying this accountThresholdKey thresholdKeys =newThresholdKey(2).add(publicKey1).add(publicKey2).add(publicKey3);//v1.2.2
JavaScript
//Generate 3 keysconstkey1=awaitEd25519PrivateKey.generate();constpublicKey1=key1.publicKey;constkey2=awaitEd25519PrivateKey.generate();constpublicKey2=key2.publicKey;constkey3=awaitEd25519PrivateKey.generate();constpublicKey3=key3.publicKey;//Create a threshold key of 2/3constthresholdKeys=newThresholdKey(2).add(publicKey1).add(publicKey2).add(publicKey3); //v1.4.2