Taseen Tanvir
Taseen Tanvir

Reputation: 1

how to actually make an auction functionality into my daap?

I've been trying to make an NFT marketplace with the functionality of auctioning an item. But I don't know how to achieve this via signing transaction.
I have tried to use almost every method of signing from web3.js, but it requires the private key of the user.
However there's the function web3.eth.signTransaction which doesn't require any private key to sign the transaction, but it gives an error on the console. saying : Error: The method 'eth_signTransaction' does not exist / is not available.
Can someone give me an overview of how this signing and sending transaction can be done implementing the functionality of auctioning an nft like nft marketplaces: opensea or foundation.

Error image

Upvotes: -1

Views: 283

Answers (1)

Petr Hejda
Petr Hejda

Reputation: 43521

From the docs:

Signs a transaction. This account needs to be unlocked.

It doesn't require the private key, but it requires the account (that is used for signing the transaction) to be unlocked on the node. Which means the node needs to hold the private key to unlock the account.

It's usually allowed on local nodes such as Ganache or private nodes.

And public nodes such as Infura usually disable this functionality (hence the error message "eth_signTransaction is not available") since they don't store your private keys.


You can ask the user to sign the transaction using their wallet. For example using MetaMask (or any other wallet implementing the Ethereum provider API):

const transactionParameters = {
  from: ethereum.selectedAddress, // must match user's active address
  to: 'your address'
};

await ethereum.request({
  method: 'eth_sendTransaction',
  params: [transactionParameters],
});

Upvotes: 1

Related Questions