({{, (RefLink[BlockchainKeyEncode, paclet:ref/BlockchainKeyEncode])[key,form]
encodes a private or public key in the specified blockchain format.}})

OpenersNotesSection(Spacer1)Details and Options

(RefLink[BlockchainKeyEncode, paclet:ref/BlockchainKeyEncode]) has the option (RefLink[BlockchainBase, paclet:ref/BlockchainBase]), with default setting (RefLink[$BlockchainBase, paclet:ref/$BlockchainBase]).

In (RefLink[BlockchainKeyEncode, paclet:ref/BlockchainKeyEncode])[key,form], key can be a (RefLink[PrivateKey, paclet:ref/PrivateKey]) or a (RefLink[PublicKey, paclet:ref/PublicKey]) object.

Possible formats specified by form include:

OpenersPrimaryExamplesSection(Spacer1)Examples  (5)

OpenersExampleSection0(Spacer1)Basic Examples  (3)

Encode a private key as a WIF-compressed format to be used in a transaction on the Bitcoin blockchain:

keys=GenerateAsymmetricKeyPair[Method-><|"Type"->"EllipticCurve","CurveName"->"Bitcoin","Compressed"-> True|> ]

BlockchainKeyEncode[keys["PrivateKey"],"WIF",BlockchainBase-> "Bitcoin"]

Encode a public key as a Pay-to-Public-Key-Hash Bitcoin address:

keys=GenerateAsymmetricKeyPair[Method-><|"Type"->"EllipticCurve","CurveName"->"Bitcoin","Compressed"-> True|> ]

BlockchainKeyEncode[keys["PublicKey"],"Address",BlockchainBase-> "Bitcoin"]

Encode a public key as an Ethereum address:

keys=GenerateAsymmetricKeyPair["Ethereum" ]

BlockchainKeyEncode[keys["PublicKey"],"Address",BlockchainBase-> "Ethereum"]

OpenersExampleSection1(Spacer1)Scope  (2)

Encode a private key as an Ethereum address:

keys=GenerateAsymmetricKeyPair["Ethereum" ]

BlockchainKeyEncode[keys["PrivateKey"],"Address",BlockchainBase-> "Ethereum"]

keys["PrivateKey"]

Encode a private key to an Ethereum address in hexadecimal string:

pKey = "4da3a53bd77c43eecbb7e38c0a25f9d7e14ab204e276cfde742bc4bfd0624ce4";

BlockchainKeyEncode[pKey,"Address",BlockchainBase-> "Ethereum"]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[BlockchainAddressData, paclet:ref/BlockchainAddressData])  ▪  (RefLink[BlockchainTransaction, paclet:ref/BlockchainTransaction])  ▪  (RefLink[BlockchainTransactionSign, paclet:ref/BlockchainTransactionSign])  ▪  (RefLink[BlockchainTransactionSubmit, paclet:ref/BlockchainTransactionSubmit])  ▪  (RefLink[GenerateAsymmetricKeyPair, paclet:ref/GenerateAsymmetricKeyPair])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Working with Blockchains, paclet:guide/Blockchain])}})}})