import { IN3 } from '../../in3/sdk-wasm.js'; export declare class Account { in3: IN3; /** initialiazes the Account API * @param in3 - the incubed Client */ constructor(in3: IN3); /** Generates 32 random bytes. * If /dev/urandom is available it will be used and should generate a secure random number. * If not the number should not be considered sceure or used in production. * * @param seed - the seed. If given the result will be deterministic. * @return the 32byte random data * * **Example** * * ```js * let result = sdk.account.createKey() * * // result = "0x6c450e037e79b76f231a71a22ff40403f7d9b74b15e014e52fe1156d3666c3e6" * ``` * */ createKey(seed?: string): string; /** extracts the address from a private key. * @param pk - the 32 bytes private key as hex. * @return the address * * **Example** * * ```js * let result = sdk.account.pk2address("0x0fd65f7da55d811634495754f27ab318a3309e8b4b8a978a50c20a661117435a") * * // result = "0xdc5c4280d8a286f0f9c8f7f55a5a0c67125efcfd" * ``` * */ pk2address(pk: string): string; /** extracts the public key from a private key. * @param pk - the 32 bytes private key as hex. * @return the public key as 64 bytes * * **Example** * * ```js * let result = sdk.account.pk2public("0x0fd65f7da55d811634495754f27ab318a3309e8b4b8a978a50c20a661117435a") * * // result = "0x0903329708d9380aca47b02f3955800179e18bffbb29be3a644593c5f87e4c7fa960983f7818\ * // 6577eccc909cec71cb5763acd92ef4c74e5fa3c43f3a172c6de1" * ``` * */ pk2public(pk: string): string; /** extracts the public key and address from signature. * @param msg - the message the signature is based on. * @param sig - the 65 bytes signature as hex. * @param sigtype - the type of the signature data : `eth_sign` (use the prefix and hash it), `raw` (hash the raw data), `hash` (use the already hashed data). Default: `raw` * @return the extracted public key and address * * **Example** * * ```js * let result = sdk.account.ecrecover("0x487b2cbb7997e45b4e9771d14c336b47c87dc2424b11590e32b3a8b9ab327999", "0x0f804ff891e97e8a1c35a2ebafc5e7f129a630a70787fb86ad5aec0758d98c7b454dee5564310d497ddfe814839c8babd3a727692be40330b5b41e7693a445b71c", "hash") * * // result = * // publicKey: "0x94b26bafa6406d7b636fbb4de4edd62a2654eeecda9505e9a478a66c4f42e504c\ * // 4481bad171e5ba6f15a5f11c26acfc620f802c6768b603dbcbe5151355bbffb" * // address: "0xf68a4703314e9a9cf65be688bd6d9b3b34594ab4" * ``` * */ ecrecover(msg: string, sig: string, sigtype?: string): AccountEcrecover; /** prepares a Transaction by filling the unspecified values and returens the unsigned raw Transaction. * @param tx - the tx-object, which is the same as specified in [eth_sendTransaction](https://eth.wiki/json-rpc/API#eth_sendTransaction). * @return the unsigned raw transaction as hex. * * **Example** * * ```js * let result = await sdk.account.prepareTx(AccountTransaction(to: "0x63f666a23cbd135a91187499b5cc51d589c302a0", value: "0x100000000", from: "0xc2b2f4ad0d234b8c135c39eea8409b448e5e496f")) * // result = "0xe980851a13b865b38252089463f666a23cbd135a91187499b5cc51d589c302a0850100000000\ * // 80018080" * ``` * */ prepareTx(tx: AccountTransaction): Promise; /** signs the given raw Tx (as prepared by in3_prepareTx ). The resulting data can be used in `eth_sendRawTransaction` to publish and broadcast the transaction. * @param tx - the raw unsigned transactiondata * @param from - the account to sign * @return the raw transaction with signature. * * **Example** * * ```js * let result = await sdk.account.signTx("0xe980851a13b865b38252089463f666a23cbd135a91187499b5cc51d589c302a085010000000080018080", "0xc2b2f4ad0d234b8c135c39eea8409b448e5e496f") * // result = "0xf86980851a13b865b38252089463f666a23cbd135a91187499b5cc51d589c302a08501000000\ * // 008026a03c5b094078383f3da3f65773ab1314e89ee76bc41f827f2ef211b2d3449e4435a077755\ * // f8d9b32966e1ad8f6c0e8c9376a4387ed237bdbf2db6e6b94016407e276" * ``` * */ signTx(tx: string, from: string): Promise; /** signs the given data. * @param msg - the message to sign. * @param account - the account to sign if the account is a bytes32 it will be used as private key * @param msgType - the type of the signature data : `eth_sign` (use the prefix and hash it), `raw` (hash the raw data), `hash` (use the already hashed data) * @return the signature * * **Example** * * ```js * let result = await sdk.account.signData("0x0102030405060708090a0b0c0d0e0f", "0xa8b8759ec8b59d7c13ef3630e8530f47ddb47eba12f00f9024d3d48247b62852", "raw") * // result = * // message: "0x0102030405060708090a0b0c0d0e0f" * // messageHash: "0x1d4f6fccf1e27711667605e29b6f15adfda262e5aedfc5db904feea2baa75e67" * // signature: "0xa5dea9537d27e4e20b6dfc89fa4b3bc4babe9a2375d64fb32a2eab04559e95792\ * // 264ad1fb83be70c145aec69045da7986b95ee957fb9c5b6d315daa5c0c3e1521b" * // r: "0xa5dea9537d27e4e20b6dfc89fa4b3bc4babe9a2375d64fb32a2eab04559e9579" * // s: "0x2264ad1fb83be70c145aec69045da7986b95ee957fb9c5b6d315daa5c0c3e152" * // v: 27 * ``` * */ signData(msg: string, account: string, msgType?: string): Promise; /** decrypts a JSON Keystore file as defined in the [Web3 Secret Storage Definition](https://github.com/ethereum/wiki/wiki/Web3-Secret-Storage-Definition). The result is the raw private key. * @param key - Keydata as object as defined in the keystorefile * @param passphrase - the password to decrypt it. * @return a raw private key (32 bytes) * * **Example** * * ```js * let result = sdk.account.decryptKey({"version":"3,","id":"f6b5c0b1-ba7a-4b67-9086-a01ea54ec638","address":"08aa30739030f362a8dd597fd3fcde283e36f4a1","crypto":{"ciphertext":"d5c5aafdee81d25bb5ac4048c8c6954dd50c595ee918f120f5a2066951ef992d","cipherparams":{"iv":"415440d2b1d6811d5c8a3f4c92c73f49"},"cipher":"aes-128-ctr","kdf":"pbkdf2","kdfparams":{"dklen":32,"salt":"691e9ad0da2b44404f65e0a60cf6aabe3e92d2c23b7410fd187eeeb2c1de4a0d","c":16384,"prf":"hmac-sha256"},"mac":"de651c04fc67fd552002b4235fa23ab2178d3a500caa7070b554168e73359610"}}, "test") * * // result = "0x1ff25594a5e12c1e31ebd8112bdf107d217c1393da8dc7fc9d57696263457546" * ``` * */ decryptKey(key: string, passphrase: string): string; /** The sign method calculates an Ethereum specific signature with: * * ```js * sign(keccak256("\x19Ethereum Signed Message:\n" + len(message) + message))). * ``` * * By adding a prefix to the message makes the calculated signature recognisable as an Ethereum specific signature. This prevents misuse where a malicious DApp can sign arbitrary data (e.g. transaction) and use the signature to impersonate the victim. * * For the address to sign a signer must be registered. * * @param account - the account to sign with * @param message - the message to sign * @return the signature (65 bytes) for the given message. * * **Example** * * ```js * let result = await sdk.account.sign("0x9b2055d370f73ec7d8a03e965129118dc8f5bf83", "0xdeadbeaf") * // result = "0xa3f20717a250c2b0b729b7e5becbff67fdaef7e0699da4de7ca5895b02a170a12d887fd3b17b\ * // fdce3481f10bea41f45ba9f709d39ce8325427b57afcfc994cee1b" * ``` * */ sign(account: string, message: string): Promise; /** Signs a transaction that can be submitted to the network at a later time using with eth_sendRawTransaction. * @param tx - transaction to sign * @return the raw signed transaction * * **Example** * * ```js * let result = await sdk.account.signTransaction(AccountTransaction(data: "0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675", from: "0xb60e8dd61c5d32be8058bb8eb970870f07233155", gas: "0x76c0", gasPrice: "0x9184e72a000", to: "0xd46e8dd67c5d32be8058bb8eb970870f07244567", value: "0x9184e72a")) * // result = "0xa3f20717a250c2b0b729b7e5becbff67fdaef7e0699da4de7ca5895b02a170a12d887fd3b17b\ * // fdce3481f10bea41f45ba9f709d39ce8325427b57afcfc994cee1b" * ``` * */ signTransaction(tx: AccountTransaction): Promise; /** adds a raw private key as signer, which allows signing transactions. * @param pk - the 32byte long private key as hex string. * @return the address of given key. * * **Example** * * ```js * let result = sdk.account.addRawKey("0x1234567890123456789012345678901234567890123456789012345678901234") * * // result = "0x2e988a386a799f506693793c6a5af6b54dfaabfb" * ``` * */ addRawKey(pk: string): string; /** returns a array of account-addresss the incubed client is able to sign with. * * In order to add keys, you can use [in3_addRawKey](#in3-addrawkey) or configure them in the config. The result also contains the addresses of any signer signer-supporting the `PLGN_ACT_SIGN_ACCOUNT` action. * * @return the array of addresses of all registered signers. * * **Example** * * ```js * let result = sdk.account.accounts() * * // result = * // - "0x2e988a386a799f506693793c6a5af6b54dfaabfb" * // - "0x93793c6a5af6b54dfaabfb2e988a386a799f5066" * ``` * */ accounts(): string[]; } /** the extracted public key and address */ export interface AccountEcrecover { /** the public Key of the signer (64 bytes) */ publicKey: string; /** the address */ address: string; } /** the tx-object, which is the same as specified in [eth_sendTransaction](https://eth.wiki/json-rpc/API#eth_sendTransaction). */ export interface AccountTransaction { /** receipient of the transaction. */ to: string; /** sender of the address (if not sepcified, the first signer will be the sender) */ from: string; /** value in wei to send */ value: bigint; /** the gas to be send along */ gas: number; /** the price in wei for one gas-unit. If not specified it will be fetched using `eth_gasPrice` */ gasPrice: number; /** the current nonce of the sender. If not specified it will be fetched using `eth_getTransactionCount` */ nonce: number; /** the data-section of the transaction */ data: string; } /** the signature */ export interface AccountSignData { /** original message used */ message: string; /** the hash the signature is based on */ messageHash: string; /** the signature (65 bytes) */ signature: string; /** the x-value of the EC-Point */ r: string; /** the y-value of the EC-Point */ s: string; /** the recovery value (0|1) + 27 */ v: string; } export default Account;