Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

execution reverted: Sell failed authorization #1

Open
kapuc92 opened this issue Apr 17, 2023 · 0 comments
Open

execution reverted: Sell failed authorization #1

kapuc92 opened this issue Apr 17, 2023 · 0 comments

Comments

@kapuc92
Copy link

kapuc92 commented Apr 17, 2023

Hello. Trying to execute, but getting error "Sell failed authorization"

What's wrong with my code?

const ethers = require("ethers");

const OracleOrder = [
  { name: 'order', type: 'Order' },
  { name: 'blockNumber', type: 'uint256' },
]
const Order = [
  { name: 'trader', type: 'address' },
  { name: 'side', type: 'uint8' },
  { name: 'matchingPolicy', type: 'address' },
  { name: 'collection', type: 'address' },
  { name: 'tokenId', type: 'uint256' },
  { name: 'amount', type: 'uint256' },
  { name: 'paymentToken', type: 'address' },
  { name: 'price', type: 'uint256' },
  { name: 'listingTime', type: 'uint256' },
  { name: 'expirationTime', type: 'uint256' },
  { name: 'fees', type: 'Fee[]' },
  { name: 'salt', type: 'uint256' },
  { name: 'extraParams', type: 'bytes' }
]
const Fee = [
  { name: 'rate', type: 'uint16' },
  { name: 'recipient', type: 'address' },
]
const domain = {
	name: 'Blur Exchange',
	version: '1.0',
	chainId: '1',
	verifyingContract: '0x000000000000ad05ccc4f10045630fb830b95127',
}

const execute = async () => {
	const node = new ethers.providers.JsonRpcProvider("https://rpc.ankr.com/eth");
	
	const listingTime = String((((Date.now() - 1000000) / 1000)).toFixed());
	const expirationTime = String(((Date.now() + 1000 * 60 * 60 * 24 * 3) / 1000).toFixed());
	const salt = "5287962905876209576"
	const block = await node.getBlockNumber();
	
	const sellOrder = {
		"trader":sellerAddress,
		"side":"1",
		"matchingPolicy":"0x00000000006411739DA1c40B106F8511de5D1FAC",
		"collection":"0xaC3748673eE62a248D859191a74FBf837A448FD3",
		"tokenId":"2",
		"amount":"1",
		"paymentToken":"0x0000000000000000000000000000000000000000",
		"price":"1000000000000000",
		"listingTime":listingTime,
		"expirationTime":expirationTime,
		"fees":[{
			"rate":"10000",
			"recipient":buyerAddress
			}],
		"salt":salt,
		"extraParams":"0x"
		}
	
	sell_signature = await sellerSigner._signTypedData(domain, {Order, Fee}, sellOrder);
	sell_signature = await ethers.utils.splitSignature(sell_signature);
	
	const buyOrder = {
		"trader":buyerAddress,
		"side":"0","matchingPolicy":"0x00000000006411739DA1c40B106F8511de5D1FAC",
		"collection":"0xaC3748673eE62a248D859191a74FBf837A448FD3",
		"tokenId":"2",
		"amount":"1",
		"paymentToken":"0x0000000000000000000000000000000000000000",
		"price":"1000000000000000",
		"listingTime":listingTime,
		"expirationTime":expirationTime,
		"fees":[],
		"salt":salt,
		"extraParams":"0x"
		}
	
	const sell = {
		"order": sellOrder,
		"v": sell_signature.v,
		"r": sell_signature.r,
		"s": sell_signature.s,
		"extraSignature": "0x",
		"signatureVersion": "0",
		"blockNumber": block
		}
	const buy = {
		"order": buyOrder,
		"v": 0,
		"r": "0x0000000000000000000000000000000000000000000000000000000000000000",
		"s": "0x0000000000000000000000000000000000000000000000000000000000000000",
		"extraSignature": "0x",
		"signatureVersion": "0",
		"blockNumber": block
		}
		console.log(JSON.stringify(sell))
		console.log(JSON.stringify(buy))
	const contract = new ethers.Contract("0x000000000000ad05ccc4f10045630fb830b95127", Blur_ABI, buyerSigner);
	const transaction = await contract.execute(
		sell, buy
	)
	console.log(transaction);
}
execute()
Repository owner deleted a comment from fede-s Feb 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
@kapuc92 and others