-
Notifications
You must be signed in to change notification settings - Fork 13
Open
Description
I'm using secret-sdk python to submit a swap to secret swap.
I can't seem to submit a valid transaction, and I think it's that the message is incorrect. I am using the example syntax given in your GitHub, but it isn't working for me.
I want to trade sSCRT for sETH, here is the message I have written by your specifications:
swap_msg = {
"swap": {
"offer_asset": {
"info": {
"native_token": {
"denom": "sSCRT"
}
},
"amount": 1
}
}
}
then I package it into a transaction:
#get message into a send message format
send_msg = secret.wasm.contract_execute_msg(wallet.key.acc_address,contract_address,swap_msg)
#get message into transaction format
tx = wallet.create_and_sign_tx(
msgs=[send_msg],
memo="",
fee=StdFee(50000, "5000uscrt")
)
#broadcast to chain
result = secret.tx.broadcast(tx)
print(result)
However, this transaction doesn't ever end up going through successfully.
I assume that the message I am submitting is incorrect; however, it's impossible to know how it should look because everything is hashed.
Here is my full code if it's of interest:
#import required dependencies
from secret_sdk.client.lcd import LCDClient
from secret_sdk.key.mnemonic import MnemonicKey
from secret_sdk.core.auth import StdFee
from secret_sdk.core.bank import MsgSend
#endpoints
node_rest_endpoint = "http://api.scrt.network/"
chain_id = "secret-4"
#create wallet from mnemonic
MNEMONIC = "my mnemonic"
secret = LCDClient(chain_id=chain_id, url=node_rest_endpoint)
mk = MnemonicKey(mnemonic=MNEMONIC)
wallet = secret.wallet(mk)
#point to sSCRT contract address
contract_address = "secret1k0jntykt7e4g3y88ltc60czgjuqdy4c9e8fzek"
#create a message for secretswap
swap_msg = {
"swap": {
"offer_asset": {
"info": {
"native_token": {
"denom": "sSCRT"
}
},
"amount": 1
}
}
}
#get message into a send message format
send_msg = secret.wasm.contract_execute_msg(wallet.key.acc_address,contract_address,swap_msg)
#get message into transaction format
tx = wallet.create_and_sign_tx(
msgs=[send_msg],
memo="",
fee=StdFee(50000, "5000uscrt")
)
#broadcast to chain
result = secret.tx.broadcast(tx)
print(result)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels