scrtlabs / secretswap Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
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)
Hello guys,
I see that SecretSwap's balances are publicly accessible, hence the viewing key is static and public,
here I see a possible attack vector, where everyone can monitor the network and see the balance changes after each tx.
Not private enough I think..
Am I right?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.