import { IN3 } from '../../in3/sdk-wasm.js'; import { ABI, Ethlog } from './eth'; export declare class Utils { in3: IN3; /** initialiazes the Utils API * @param in3 - the incubed Client */ constructor(in3: IN3); /** clears the incubed cache (usually found in the .in3-folder) * @return true indicating the success * * **Example** * * ```js * let result = sdk.utils.cacheClear() * * // result = true * ``` * */ cacheClear(): string; /** Returns the underlying client version. See [web3_clientversion](https://eth.wiki/json-rpc/API#web3_clientversion) for spec. * @return when connected to the incubed-network, `Incubed/` will be returned, but in case of a direct enpoint, its's version will be used. */ clientVersion(): Promise; /** Returns Keccak-256 (not the standardized SHA3-256) of the given data. * * See [web3_sha3](https://eth.wiki/json-rpc/API#web3_sha3) for spec. * * No proof needed, since the client will execute this locally. * * @param data - data to hash * @return the 32byte hash of the data * * **Example** * * ```js * let result = sdk.utils.sha3("0x1234567890") * * // result = "0x3a56b02b60d4990074262f496ac34733f870e1b7815719b46ce155beac5e1a41" * ``` * */ sha3(data: string): string; /** Will convert an upper or lowercase Ethereum address to a checksum address. (See [EIP55](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-55.md) ) * @param address - the address to convert. * @param useChainId - if true, the chainId is integrated as well (See [EIP1191](https://github.com/ethereum/EIPs/issues/1121) ) * @return the address-string using the upper/lowercase hex characters. * * **Example** * * ```js * let result = sdk.utils.checksumAddress("0x1fe2e9bf29aa1938859af64c413361227d04059a", false) * * // result = "0x1Fe2E9bf29aa1938859Af64C413361227d04059a" * ``` * */ checksumAddress(address: string, useChainId?: boolean): string; /** converts the given value into wei. * @param value - the value, which may be floating number as string * @param unit - the unit of the value, which must be one of `wei`, `kwei`, `Kwei`, `babbage`, `femtoether`, `mwei`, `Mwei`, `lovelace`, `picoether`, `gwei`, `Gwei`, `shannon`, `nanoether`, `nano`, `szabo`, `microether`, `micro`, `finney`, `milliether`, `milli`, `ether`, `eth`, `kether`, `grand`, `mether`, `gether` or `tether` * @return the value in wei as hex. * * **Example** * * ```js * let result = sdk.utils.toWei("20.0009123", "eth") * * // result = "0x01159183c4793db800" * ``` * */ toWei(value: string, unit?: string): string; /** converts a given uint (also as hex) with a wei-value into a specified unit. * @param value - the value in wei * @param unit - the unit of the target value, which must be one of `wei`, `kwei`, `Kwei`, `babbage`, `femtoether`, `mwei`, `Mwei`, `lovelace`, `picoether`, `gwei`, `Gwei`, `shannon`, `nanoether`, `nano`, `szabo`, `microether`, `micro`, `finney`, `milliether`, `milli`, `ether`, `eth`, `kether`, `grand`, `mether`, `gether` or `tether` * @param digits - fix number of digits after the comma. If left out, only as many as needed will be included. * @return the value as string. * * **Example** * * ```js * let result = sdk.utils.fromWei("0x234324abadefdef", "eth", 3) * * // result = "0.158" * ``` * */ fromWei(value: bigint, unit: string, digits?: number): string; /** calculates the address of a contract about to deploy. The address depends on the senders nonce. * @param sender - the sender of the transaction * @param nonce - the nonce of the sender during deployment * @return the address of the deployed contract * * **Example** * * ```js * let result = await sdk.utils.calcDeployAddress("0x5a0b54d5dc17e0aadc383d2db43b0a0d3e029c4c", 6054986) * // result = "0xba866e7bd2573be3eaf5077b557751bb6d58076e" * ``` * */ calcDeployAddress(sender: string, nonce?: number): Promise; /** the Network Version (currently 1) * @return the Version number */ version(): string; createSignatureHash(def: ABI): string; decodeEvent(log: Ethlog, d: ABI): any; soliditySha3(...args: any[]): string; /** * encodes the given arguments as ABI-encoded (including the methodHash) * @param signature the method signature * @param args the arguments */ abiEncode(signature: string, ...args: any[]): string; /** * decodes the given data as ABI-encoded (without the methodHash) * @param signature the method signature, which must contain a return description * @param data the data to decode */ abiDecode(signature: string, data: string): any[]; /** * generates a checksum Address for the given address. * If the chainId is passed, it will be included accord to EIP 1191 * @param address the address (as hex) * @param chainId the chainId (if supported) */ toChecksumAddress(address: string, chainId?: number): string; /** * checks whether the given address is a correct checksumAddress * If the chainId is passed, it will be included accord to EIP 1191 * @param address the address (as hex) * @param chainId the chainId (if supported) */ checkAddressChecksum(address: string, chainId?: number): boolean; /** * checks whether the given address is a valid hex string with 0x-prefix and 20 bytes * @param address the address (as hex) */ isAddress(address: string): boolean; /** * calculates the keccack hash for the given data. * @param data the data as Uint8Array or hex data. */ keccak(data: Uint8Array | string): Uint8Array; /** * calculates the sha256 hash for the given data. * @param data the data as Uint8Array or hex data. */ sha256(data: Uint8Array | string): Uint8Array; /** * returns a Buffer with strong random bytes. * Thsi will use the browsers crypto-module or in case of nodejs use the crypto-module there. * @param len the number of bytes to generate. */ randomBytes(len: number): Uint8Array; /** * converts any value to a hex string (with prefix 0x). * optionally the target length can be specified (in bytes) */ toHex(data: any, len?: number): string; /** * returns the incubed version. */ getVersion(): string; /** removes all leading 0 in the hexstring */ toMinHex(key: any): string; /** * converts any value to a Uint8Array. * optionally the target length can be specified (in bytes) */ toUint8Array(data: any, len?: number): Uint8Array; /** * converts any value to a hex string (with prefix 0x). * optionally the target length can be specified (in bytes) */ toNumber(data: any): number; /** * convert to String */ toUtf8(val: any): string; /** * create a signature (65 bytes) for the given message and kexy * @param pk the private key * @param msg the message * @param hashFirst if true the message will be hashed first (default:true), if not the message is the hash. * @param adjustV if true (default) the v value will be adjusted by adding 27 */ ecSign(pk: string | Uint8Array, msg: string | Uint8Array, hashFirst?: boolean, adjustV?: boolean): Uint8Array; /** * takes raw signature (65 bytes) and splits it into a signature object. * @param signature the 65 byte-signature * @param message the message * @param hashFirst if true (default) this will be taken as raw-data and will be hashed first. */ splitSignature(signature: string | Uint8Array, message: Uint8Array | string, hashFirst?: boolean): import("../../in3/sdk-wasm.js").Signature; /** * generates the public address from the private key. * @param pk the private key. */ private2address(pk: string | Uint8Array): string; /** * generates the public address (64 bytes) from the private key * @param pk the raw private key */ private2public(pk: string | Uint8Array): Uint8Array; } export default Utils;