sendTransaction based on sendToken
See original GitHub issueThere could be a more generalized version of sendToken that sends a custom transaction. So, it would get account number, sequence and chain id, use an existing client, post request (base_req and body) to an API to get a formed tx, sign it locally and broadcast it to the chain.
Something like this:
async sendTransaction({ state }, { type, body }) { // don't mind the state, it's a Vuex thing
const { accountNumber, sequence } = await state.client.getNonce();
const address = state.client.senderAddress;
const chain_id = await state.client.getChainId();
const req = {
base_req: { chain_id, from: address },
creator: address,
...body,
};
const { data } = await axios.post(`${API}/${chain_id}/${type}`, req);
const { msg, fee, memo } = data.value;
const signBytes = makeSignBytes(
msg,
fee,
chain_id,
memo,
accountNumber,
sequence
);
const signatures = [await state.wallet.sign(signBytes)];
const signedTx = { msg: msg, fee, memo, signatures };
return await state.client.postTx(signedTx);
}
Pretty useful method to have.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
web3 sendTransaction select and send token different than ...
I simply want to send ETH, but on the Polygon Network. Can someone guide me? I am using web3.min.js and spent hours on...
Read more >How to call my contract's function using sendTransaction
Posting solution to my own question for anyone who needs it. To call a contract function from geth :
Read more >Send Transactions | Flow Blockchain
sendTransaction (props). Send transaction to network. Provides explicit control over how you pass values.
Read more >Sending Tokens Using ethers.js - Ethereum.org
Send Token Using ethers.js(5.0). In This Tutorial You'll Learn How To. Import ethers.js; Transfer token; Set gas price according to the ...
Read more >How to send ERC20 token with Web3.js | by Hideyoshi Moriya
ABI is an interface which represents what functions/state variables a smart contract has. To interact with smart contracts with Web3.js, ABI is ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Very good idea.
Looking at
packages/cosmwasm/src/signingcosmwasmclient.ts
you also see a lot of repetition of this code:So the same
sendTransaction
should be created inSigningCosmWasmClient
andSigningCosmosClient
Thank you Ethan! I agree this is a more general solution to the problem. However, I don’t think we will get it sufficiently refned and implemented this week and in 0.22.0. I created a new ticket here: https://github.com/CosmWasm/cosmjs/issues/316. I’ll close this ticket with a smaller change of the current code.