Liking cljdoc? Tell your friends :D

cljs-web3-next.core


address?cljs

(address? address)
(address? Web3 address)

Returns a boolean indicating if the given string is an address.

Parameters: address - An HEX string. Web3 - (Optional first argument) Web3 JavaScript object

Returns false if it's not on a valid address format. Returns true if it's an all lowercase or all uppercase valid address. If it's a mixed case address, it checks using web3's isChecksumAddress().

Example: user> (address? "0x8888f1f195afa192cfee860698584c030f4c9db1") true

;; With first f capitalized user> (web3/address? "0x8888F1f195afa192cfee860698584c030f4c9db1") false

Returns a boolean indicating if the given string is an address.

Parameters:
address - An HEX string.
Web3    - (Optional first argument) Web3 JavaScript object

Returns false if it's not on a valid address format. Returns true if it's an
all lowercase or all uppercase valid address. If it's a mixed case address, it
checks using web3's isChecksumAddress().

Example:
user> `(address? "0x8888f1f195afa192cfee860698584c030f4c9db1")`
true

;; With first f capitalized
user> `(web3/address? "0x8888F1f195afa192cfee860698584c030f4c9db1")`
false
raw docstring

connectcljs

(connect provider)

connected?cljs

(connected? provider)

connection-urlcljs

(connection-url provider)

create-web3cljs

(create-web3 url)
(create-web3 provider url)

Creates a web3 instance using given provider or from URL using appropriate provider based on the URL (ws_:// or http_://).

Parameters: url - The URL string for which to create the provider. web3-provider - instance of https://web3js.readthedocs.io/en/v1.7.3/web3-eth.html#providers Normally this would be the window.ethereum (injected by MetaMask, after user has authorized it)

Creates a web3 instance using given provider or from URL using appropriate provider
 based on the URL (ws_:// or http_://).

Parameters:
url           - The URL string for which to create the provider.
web3-provider - instance of https://web3js.readthedocs.io/en/v1.7.3/web3-eth.html#providers
                Normally this would be the `window.ethereum` (injected by MetaMask, after user
                has authorized it)
raw docstring

current-providercljs

(current-provider web3)

Will contain the current provider, if one is set. This can be used to check if Mist etc. already set a provider.

Parameters: web3 - web3 instance

Returns the provider set or nil.

Will contain the current provider, if one is set. This can be used to check
if Mist etc. already set a provider.

Parameters:
web3 - web3 instance

Returns the provider set or nil.
raw docstring

default-web3cljs

(default-web3)

disconnectcljs

(disconnect provider)

extendcljs

(extend provider property methods)

from-asciicljs

(from-ascii string)
(from-ascii Web3 string)

Converts any ASCII string to a HEX string.

Parameters: string - An ASCII string to be converted to HEX. Web3 - (optional first argument) Web3 JavaScript object.

Example: user> (from-ascii "ethereum") "0x657468657265756d"

Converts any ASCII string to a HEX string.

Parameters:
string  - An ASCII string to be converted to HEX.
Web3    - (optional first argument) Web3 JavaScript object.

Example:
user> `(from-ascii "ethereum")`
"0x657468657265756d"
raw docstring

from-decimalcljs

(from-decimal number)
(from-decimal Web3 number)

Converts a number or number string to its HEX representation.

renamed to numberToHex in 1.0

Parameters: number - A number to be converted to a HEX string. Web3 - (optional first argument) Web3 JavaScript object.

Example: user-> (web3/from-decimal 21) "0x15"

Converts a number or number string to its HEX representation.

renamed to numberToHex in 1.0

Parameters:
number - A number to be converted to a HEX string.
Web3   - (optional first argument) Web3 JavaScript object.

Example:
user-> `(web3/from-decimal 21)`
"0x15"
raw docstring

from-weicljs

(from-wei number unit)
(from-wei Web3 number unit)

Converts a number of Wei into an Ethereum unit.

Parameters: number - A string or BigNumber instance. unit - One of :noether :wei :kwei :Kwei :babbage :femtoether :mwei :Mwei :lovelace :picoether :gwei :Gwei :shannon :nanoether :nano :szabo :microether :micro :finney :milliether :milli :ether :kether :grand :mether :gether :tether Web3 - (optional first argument) Web3 JavaScript object.

Returns either a number string, or a BigNumber instance, depending on the given number parameter.

Example: user> (web3/from-wei "10" :ether) "0.00000000000000001"

Converts a number of Wei into an Ethereum unit.

Parameters:
number - A string or BigNumber instance.
unit   - One of :noether :wei :kwei :Kwei :babbage :femtoether :mwei :Mwei
         :lovelace :picoether :gwei :Gwei :shannon :nanoether :nano :szabo
         :microether :micro :finney :milliether :milli :ether :kether :grand
         :mether :gether :tether
Web3   - (optional first argument) Web3 JavaScript object.

Returns either a number string, or a BigNumber instance, depending on the
given number parameter.

Example:
user> `(web3/from-wei "10" :ether)`
"0.00000000000000001"
raw docstring

http-providercljs

(http-provider uri)
(http-provider uri web3-library)

ipc-providercljs

(ipc-provider Web3 uri)

on-connectcljs

(on-connect provider & [callback])

on-disconnectcljs

(on-disconnect provider & [callback])

on-errorcljs

(on-error provider & [callback])

pad-leftcljs

(pad-left string chars)
(pad-left string chars sign)
(pad-left Web3 string chars sign)

Returns input string with zeroes or sign padded to the left.

Parameters: string - String to be padded chars - Amount of chars to address sign - (optional) Char to pad with (behaviour with multiple chars is undefined) Web3 - (optional first argument) Web3 JavaScript object.

Example: user> (web3/pad-left "foo" 8) "00000foo" user> (web3/pad-left "foo" 8 "b") "bbbbbfoo"

Returns input string with zeroes or sign padded to the left.

Parameters:
string - String to be padded
chars  - Amount of chars to address
sign   - (optional) Char to pad with (behaviour with multiple chars is
                    undefined)
Web3   - (optional first argument) Web3 JavaScript object.

Example:
user> `(web3/pad-left "foo" 8)`
"00000foo"
user> `(web3/pad-left "foo" 8 "b")`
"bbbbbfoo" 
raw docstring

pad-rightcljs

(pad-right string chars)
(pad-right string chars sign)
(pad-right Web3 string chars sign)

Returns input string with zeroes or sign padded to the right.

Parameters: string - String to be padded chars - Amount of total chars sign - (optional) Char to pad with (behaviour with multiple chars is undefined) Web3 - (optional first argument) Web3 instance

Example: user> (web3/pad-right "foo" 8) "foo00000" user> (web3/pad-right "foo" 8 "b") "foobbbbb"

Returns input string with zeroes or sign padded to the right.

Parameters:
string - String to be padded
chars  - Amount of total chars
sign   - (optional) Char to pad with (behaviour with multiple chars is
                    undefined)
Web3   - (optional first argument) Web3 instance

Example:
user> `(web3/pad-right "foo" 8)`
"foo00000"
user> `(web3/pad-right "foo" 8 "b")`
"foobbbbb" 
raw docstring

resetcljs

(reset web3)
(reset web3 keep-is-syncing?)

Should be called to reset the state of web3. Resets everything except the manager. Uninstalls all filters. Stops polling.

was a breaking change in 1.0, reset() removed shimming to setProvider(currentProvider)

Parameters: web3 - An instance of web3 keep-is-syncing? - If true it will uninstall all filters, but will keep the web3.eth.isSyncing() polls

Returns nil.

Example: user> (reset web3-instance true) nil

Should be called to reset the state of web3. Resets everything except the manager.
Uninstalls all filters. Stops polling.

was a breaking change in 1.0, reset() removed shimming to setProvider(currentProvider)

Parameters:
web3             - An instance of web3
keep-is-syncing? - If true it will uninstall all filters, but will keep the
                   web3.eth.isSyncing() polls

Returns nil.

Example:
user> `(reset web3-instance true)`
nil
raw docstring

set-providercljs

(set-provider web3 provider)

Should be called to set provider.

Parameters: web3 - Web3 instance provider - the provider

Available providers in web3-cljs:

  • http-provider
  • ipc-provider

Example: user> (set-provider web3-instance (http-provider web3-instance "http://localhost:8545")) nil

Should be called to set provider.

Parameters:
web3     - Web3 instance
provider - the provider

Available providers in web3-cljs:
- `http-provider`
- `ipc-provider`

Example:
user> `(set-provider web3-instance
                     (http-provider web3-instance "http://localhost:8545"))`
nil
raw docstring

sha3cljs

(sha3 string)
(sha3 Web3 string)

Returns a string representing the Keccak-256 SHA3 of the given data.

Breaking change in 1.0: options are not accepted

Parameters: String - The string to hash using the Keccak-256 SHA3 algorithm Map - (optional) Set encoding to hex if the string to hash is encoded in hex. A leading 0x will be automatically ignored. Web3 - (optional first argument) Web3 JavaScript object.

Example: user> (def hash "Some string to be hashed") #'user/hash user> (sha3 hash) "0xed973b234cf2238052c9ac87072c71bcf33abc1bbd721018e0cca448ef79b379" user> (sha3 hash {:encoding :hex}) "0xbd83a94d23235dd7dfcf67a5a0d9e9643a715cd5b528083a2cf944d61f8e7b51"

NOTE: This differs from the documented result of the Web3 JavaScript API, which equals "0x85dd39c91a64167ba20732b228251e67caed1462d4bcf036af88dc6856d0fdcc"

Returns a string representing the Keccak-256 SHA3 of the given data.

Breaking change in 1.0: options are not accepted

Parameters:
String - The string to hash using the Keccak-256 SHA3 algorithm
Map    - (optional) Set encoding to hex if the string to hash is encoded
                    in hex. A leading 0x will be automatically ignored.
Web3   - (optional first argument) Web3 JavaScript object.

Example:
user> (def hash "Some string to be hashed")
#'user/hash
user> `(sha3 hash)
"0xed973b234cf2238052c9ac87072c71bcf33abc1bbd721018e0cca448ef79b379"`
user> `(sha3 hash {:encoding :hex})`
"0xbd83a94d23235dd7dfcf67a5a0d9e9643a715cd5b528083a2cf944d61f8e7b51"

NOTE: This differs from the documented result of the Web3 JavaScript API,
which equals
"0x85dd39c91a64167ba20732b228251e67caed1462d4bcf036af88dc6856d0fdcc"
raw docstring

support-subscriptions?cljs

(support-subscriptions? provider)

to-asciicljs

(to-ascii hex-string)
(to-ascii Web3 hex-string)

Converts a HEX string into a ASCII string.

Parameters: hex-string - A HEX string to be converted to ASCII. Web3 - (optional first argument) Web3 JavaScript object.

Example: user> (to-ascii "0x666f6f") "foo"

Converts a HEX string into a ASCII string.

Parameters:
hex-string - A HEX string to be converted to ASCII.
Web3       - (optional first argument) Web3 JavaScript object.

Example:
user> `(to-ascii "0x666f6f")`
"foo" 
raw docstring

to-big-numbercljs

(to-big-number number-or-hex-string)
(to-big-number Web3 number-or-hex-string)

Converts a given number into a BigNumber instance.

renamed to toBN in 1.0

Parameters: number-or-hex-string - A number string or HEX string of a number. Web3 - (optional first argument) Web3 JavaScript object.

Example: user> (to-big-number "10000000000000000000") <An instance of BigNumber>

Converts a given number into a BigNumber instance.

renamed to toBN in 1.0

Parameters:
number-or-hex-string - A number string or HEX string of a number.
Web3                 - (optional first argument) Web3 JavaScript object.

Example:
user> `(to-big-number "10000000000000000000")`
<An instance of BigNumber>
raw docstring

to-decimalcljs

(to-decimal hex-string)
(to-decimal Web3 hex-string)

Returns the number representing a HEX string in its number representation.

renamed to hexToNumber in 1.0

Parameters: hex-string - An HEX string to be converted to a number. Web3 - (optional first argument) Web3 JavaScript object.

Example: user> (to-decimal "0x15") 21

Returns the number representing a HEX string in its number representation.

renamed to hexToNumber in 1.0

Parameters:
hex-string - An HEX string to be converted to a number.
Web3       - (optional first argument) Web3 JavaScript object.

Example:
user> `(to-decimal "0x15")`
21
raw docstring

to-hexcljs

(to-hex any)
(to-hex Web3 any)

Returns hexadecimal string representation of any value string|number|map|set|BigNumber.

Parameters: Any - The value to parse Web3 - (optional first argument) Web3 JavaScript object.

Example: user> (to-hex "foo") "0x666f6f"

Returns hexadecimal string representation of any value
string|number|map|set|BigNumber.

Parameters:
Any  - The value to parse
Web3 - (optional first argument) Web3 JavaScript object.

Example:
user> `(to-hex "foo")`
"0x666f6f" 
raw docstring

to-weicljs

(to-wei number unit)
(to-wei Web3 number unit)

Converts an Ethereum unit into Wei.

Parameters: number - A string or BigNumber instance. unit - One of :noether :wei :kwei :Kwei :babbage :femtoether :mwei :Mwei :lovelace :picoether :gwei :Gwei :shannon :nanoether :nano :szabo :microether :micro :finney :milliether :milli :ether :kether :grand :mether :gether :tether Web3 - (optional first argument) Web3 JavaScript object.

Returns either a number string, or a BigNumber instance, depending on the given number parameter.

Example: user> (web3/to-wei "10" :ether) "10000000000000000000"

Converts an Ethereum unit into Wei.

Parameters:
number - A string or BigNumber instance.
unit   - One of :noether :wei :kwei :Kwei :babbage :femtoether :mwei :Mwei
         :lovelace :picoether :gwei :Gwei :shannon :nanoether :nano :szabo
         :microether :micro :finney :milliether :milli :ether :kether :grand
         :mether :gether :tether
Web3   - (optional first argument) Web3 JavaScript object.

Returns either a number string, or a BigNumber instance, depending on the
given number parameter.

Example:
user> `(web3/to-wei "10" :ether)`
"10000000000000000000"
raw docstring

version-apicljs

Returns a hexadecimal string representing the Ethereum protocol version. Parameters: web3 - web3 instance callback-fn - callback with two parameters, error and result Example: user> (version-ethereum web3-instance (fn [err res] (when-not err (println res)))) nil user> 0x3f

Returns a hexadecimal string representing the Ethereum protocol version.
Parameters:
web3        - web3 instance
callback-fn - callback with two parameters, error and result
Example:
user> `(version-ethereum web3-instance
         (fn [err res] (when-not err (println res))))`
nil
user> 0x3f
raw docstring

version-ethereumcljs

Returns a hexadecimal string representing the Ethereum protocol version. Parameters: web3 - web3 instance callback-fn - callback with two parameters, error and result Example: user> (version-ethereum web3-instance (fn [err res] (when-not err (println res)))) nil user> 0x3f

Returns a hexadecimal string representing the Ethereum protocol version.
Parameters:
web3        - web3 instance
callback-fn - callback with two parameters, error and result
Example:
user> `(version-ethereum web3-instance
         (fn [err res] (when-not err (println res))))`
nil
user> 0x3f
raw docstring

web3cljs

(web3)

Return the web3 instance injected via Mist or Metamask

Breaking change in MM, MM no longer injects web3 Shimming to global currentProvider

Return the web3 instance injected via Mist or Metamask

Breaking change in MM, MM no longer injects web3
Shimming to global currentProvider
raw docstring

websocket-providercljs

(websocket-provider uri)
(websocket-provider uri opts)
(websocket-provider uri opts web3-library)
Docs:
@see https://github.com/web3/web3.js/tree/1.x/packages/web3-providers-ws#usage
@see https://github.com/theturtle32/WebSocket-Node/blob/v1.0.31/docs/WebSocketClient.md#client-config-options
raw docstring

ws-providercljs

(ws-provider uri)
(ws-provider uri opts)

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close