Skip to content

Commit 297817c

Browse files
committed
Add spotDeploy example
1 parent 636d60e commit 297817c

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

examples/spot_deploy.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
from hyperliquid.utils import constants
2+
from hyperliquid.utils.signing import (
3+
sign_l1_action,
4+
get_timestamp_ms,
5+
)
6+
import example_utils
7+
8+
TOKEN_ID = 177
9+
IS_MAINNET = True
10+
11+
def main():
12+
13+
_, _, exchange = example_utils.setup(constants.MAINNET_API_URL if IS_MAINNET else constants.TESTNET_API_URL, skip_ws=True)
14+
15+
# pick a noce
16+
nonce = get_timestamp_ms()
17+
18+
# action json
19+
action = {
20+
"type": "spotDeploy",
21+
"userGenesis":{
22+
"token": TOKEN_ID,
23+
# note: address should use lowercase, uppercase would cause signature error.
24+
"userAndWei": [["0x553e545d85e2afb67c8b5223f51fe97e7dde8b74","3299999300000000"]],
25+
"existingTokenAndWei": []
26+
}
27+
}
28+
29+
# sign
30+
signature = sign_l1_action(exchange.wallet, action, None, nonce, IS_MAINNET)
31+
32+
# post
33+
response = exchange._post_action(action, signature, nonce)
34+
35+
print(response)
36+
37+
if __name__ == "__main__":
38+
main()

0 commit comments

Comments
 (0)