Comments (3)
Hmm ... When I use the same seed phrase and password that I use for the sollet wallet, the recovered pubkey is not the same
solana-keygen recover
[recover] seed phrase:
[recover] If this seed phrase has an associated passphrase, enter it now. Otherwise, press ENTER to continue:
Recovered pubkey `[not-the-same-as-sollet.io]`. Continue? (y/n):
When using solana-keygen recover
it should produce the same pubkey as my sollet wallet when I use the same seed phrase and password right?
from serum-js.
It's the same for solana-keygen pubkey ASK
.. entering the seed phrase and password that I use for the sollet wallet produces and different public key output
solana-keygen pubkey ASK
[pubkey recovery] seed phrase:
[pubkey recovery] If this seed phrase has an associated passphrase, enter it now. Otherwise, press ENTER to continue:
Enter same passphrase again:
from serum-js.
OK, I'm sure I've done this the hard way but I've figured out a method that works.
For posterity and anyone else looking for the same thing here's what I have (using Typescript):
Create a function to return an Account
object from the seed phrase only used to create a wallet on sollet.io
import * as bip32 from "bip32"
import * as bip39 from "bip39"
import { Account } from "@solana/web3.js"
import nacl from "tweetnacl"
export const wallet = async (mnemonic: string) => {
const seed = await bip39.mnemonicToSeed(mnemonic)
// console.log(seed)
const walletIndex = 0
const accountIndex = 0
const derivedSeed = bip32.fromSeed(seed).derivePath(`m/501'/${walletIndex}'/0/${accountIndex}`).privateKey
// console.log(derivedSeed)
const account = new Account(nacl.sign.keyPair.fromSeed(derivedSeed!).secretKey)
// console.log(account.publicKey.toString())
// console.log(account.secretKey.toString())
return account
}
Now use that function in some code to query open orders for the FTT/USDC market on Serum Dex:
import { Connection } from "@solana/web3.js"
import { MARKETS, Market } from "@project-serum/serum"
import { wallet } from "./wallet"
if (!process.env.MNEMONIC) throw "Missing required Env var: MNEMONIC"
const fttUsdc = MARKETS.filter((item: any) => item.name === "FTT/USDC")[0]
// console.log(fttUsdc)
let connection = new Connection("https://api.mainnet-beta.solana.com/")
async function main() {
let owner = await wallet(process.env.MNEMONIC!)
let market = await Market.load(connection, fttUsdc.address, undefined, fttUsdc.programId)
// console.log(market)
// Retrieving open orders by owner
// console.log(owner.publicKey.toString())
let myOrders = await market.loadOrdersForOwner(connection, owner.publicKey)
// console.log(myOrders)
for (let order of myOrders) {
console.log(order)
}
}
main()
.then((res) => console.log(res))
.catch((err) => console.log(err))
from serum-js.
Related Issues (12)
- What should we put for the market address public key? HOT 12
- Abstract away the Solana primitives HOT 1
- No instruction index for token `approve`
- Market addresses and DEX_PROGRAM_ID. for testnet/devnet HOT 1
- `payer` refer to different things in `serum-js` and `crank` HOT 1
- Fill event price logic HOT 1
- Make tokens_and_markets.ts more parse friendly HOT 3
- I have an issue with fetching market data. HOT 3
- how to get the trade status and the trade balance changed and histroy? HOT 2
- how much time it need to take for order show after the order placed? HOT 1
- Provide a centralised conversion from binary to language specific format HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from serum-js.