Node Wallet
dYdX wallet derivation and signing helpers.
KeyPair
dataclass
Secp256k1 key pair used for Cosmos direct signing.
Source code in pkg/src/dydx/node/wallet.py
key
instance-attribute
Private key used for signing.
public_key_bytes
property
Return the compressed public key bytes.
Returns:
| Type | Description |
|---|---|
bytes
|
Compressed secp256k1 public key bytes. |
from_hex(value)
classmethod
from_mnemonic(mnemonic)
classmethod
Wallet
dataclass
dYdX wallet plus account metadata required for signing.
Source code in pkg/src/dydx/node/wallet.py
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 | |
account_number = 0
class-attribute
instance-attribute
Cosmos account number used in direct-sign documents.
address
property
Return the dYdX bech32 account address.
Returns:
| Type | Description |
|---|---|
str
|
dYdX bech32 account address derived from the compressed public key. |
key_pair
instance-attribute
Secp256k1 key pair used for signing.
public_key
property
Return the Cosmos secp256k1 public key message.
Returns:
| Type | Description |
|---|---|
PubKey
|
Cosmos secp256k1 public key protobuf message. |
sequence = 0
class-attribute
instance-attribute
Cosmos account sequence used by the next signed transaction.
from_hex(value, *, account_number=0, sequence=0)
classmethod
Create a wallet from a hex private key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
str
|
Hex-encoded private key. |
required |
account_number
|
int
|
Cosmos account number to attach to the wallet. |
0
|
sequence
|
int
|
Cosmos account sequence to attach to the wallet. |
0
|
Returns:
| Type | Description |
|---|---|
Wallet
|
Wallet with key material and account metadata. |
Source code in pkg/src/dydx/node/wallet.py
from_mnemonic(mnemonic, *, account_number=0, sequence=0)
classmethod
Create a wallet from a mnemonic.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mnemonic
|
str
|
BIP-39 mnemonic phrase. |
required |
account_number
|
int
|
Cosmos account number to attach to the wallet. |
0
|
sequence
|
int
|
Cosmos account sequence to attach to the wallet. |
0
|
Returns:
| Type | Description |
|---|---|
Wallet
|
Wallet with key material and account metadata. |
Source code in pkg/src/dydx/node/wallet.py
sign(message)
with_account(*, account_number, sequence)
Return a wallet copy with account metadata.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
account_number
|
int
|
Cosmos account number. |
required |
sequence
|
int
|
Cosmos account sequence. |
required |
Returns:
| Type | Description |
|---|---|
Wallet
|
Wallet copy with the same key pair and updated account metadata. |
Source code in pkg/src/dydx/node/wallet.py
canonize_signature(signature)
Return the canonical 64-byte secp256k1 signature.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
signature
|
bytes
|
Recoverable secp256k1 signature bytes. |
required |
Returns:
| Type | Description |
|---|---|
bytes
|
Canonical |
Source code in pkg/src/dydx/node/wallet.py
private_key_bytes_from_mnemonic(mnemonic)
Derive the default Cosmos private key from a mnemonic.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mnemonic
|
str
|
BIP-39 mnemonic phrase. |
required |
Returns:
| Type | Description |
|---|---|
bytes
|
Raw private key bytes for the default Cosmos derivation path. |