I keep receiving
API Error 400: ['Expected exchange contract address to match']
when executing the code below:
const Web3 = require('web3')
const opensea = require('opensea-js')
const HDWalletProvider = require("@truffle/hdwallet-provider");
const provider = new HDWalletProvider({
mnemonic: "myPhrase",
providerOrUrl: "wss://rinkeby.infura.io/ws/v3/myID",
addressIndex: 0
});
console.log("test1")
const seaport = new opensea.OpenSeaPort(provider, {
networkName: opensea.Network.Rinkeby, // Main network:opensea.Network.Main
//apiKey: No API key used
})
console.log("test2")
const call = async () => {
const accountAddress = "0xcB189FD4D7C924fC4b607B7f05c02989Be9F1aE4"
const tokenId = 12
const tokenAddress = "0x0e9076fbeb063ead63b9eeb84b41694a8bbf8ddb" //https://testnets.opensea.io/assets/0x0e9076fbeb063ead63b9eeb84b41694a8bbf8ddb/12
console.log("test3")
const offer = await seaport.createBuyOrder({
asset: {
tokenId: tokenId,
tokenAddress: tokenAddress,
schemaName:"ERC721"
},
accountAddress: accountAddress,
startAmount: 0.005,
paymentTokenAddress:'0xc778417e063141139fce010982780140aa0cd5ab'
})
console.log("success")
}
call().catch((error) => {
console.error(error)
})
My truffle-config.js looks like this
const HDWalletProvider = require("@truffle/hdwallet-provider");
const mnemonic = "myPhrase";
module.exports = {
networks: {
rinkeby: {
provider: function() {
return new HDWalletProvider(mnemonic, "wss://rinkeby.infura.io/ws/v3/myID")
},
network_id: 4
}
}
}
Some things to add
- I have enough wETH on my metamask account to conduct this transaction (i.e. 0.1 rinkeby wETH)
- When executing the same code, i also get the "request timed out" error very often. the following errorcode shows that there are some issues with truffle (or anything reporting to truffle)
- I am very new to this. Thus there is the potential that I missed something rather basic
I appreciate any help!