我正在尝试将 NFT 发送到智能合约以进行托管,但在实现 onERC721Received 的重写函数时遇到了困难,因为我收到了有关未使用变量的错误 - 这是我收到的错误吗?
Warning: Unused function parameter. Remove or comment out the variable name to silence this warning.
--> contracts/NftEscrow.sol:11:79:
|
11 | function onERC721Received(address _operator, address _from, uint256 _tokenId, bytes memory _data) public override returns(bytes4) {
| ^^^^^^^^^^^^^^^^^^
Run Code Online (Sandbox Code Playgroud)
这就是智能合约
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";
contract nftescrow is IERC721Receiver {
enum ProjectState {newEscrow, nftDeposited, cancelNFT, ethDeposited, canceledBeforeDelivery, deliveryInitiated, delivered}
address payable public sellerAddress;
address payable public buyerAddress;
address public nftAddress;
uint256 tokenID;
bool buyerCancel = false;
bool …Run Code Online (Sandbox Code Playgroud) 我在混音运行中调度操作时遇到了一些麻烦 - 我有一个旁白,其中包含我购物车中的所有数据 - 我有一个整理所有数据的表单 - 当我想要创建结帐时我想调用该操作
<Form action='/products' method="post">
{cart.map((item, idx) => (
<div key={idx}>
<input readOnly value={item.product.id} type="hidden" name="id"/>
<input readOnly value={item.quantity} type="hidden" name="quantity"/>
</div>
))}
<button
className="mr-2 m"
> Add to Cart
</button>
</Form>
export const action: ActionFunction = async ({request}) => {
// get the form data from the POST
const formData = await request.formData()
const id = formData.getAll('id')
const quantity = formData.getAll('quantity')
const newObj = id.map((data, index) => {
return { variantId: data, quantity: quantity[index] …Run Code Online (Sandbox Code Playgroud) 我在使用 remix run 将数据发送到服务器时遇到问题 - 我不确定我是否完全理解 useAction 数据的工作原理。我了解 useLoaderData 函数的工作原理,但是当您尝试将数据发送到服务器时,我会收到错误。
我想要做的是当我单击按钮时向我的服务器发送一个发布请求 - 如果我尝试在handleCLick事件中调用create cart,它会说createCart不是一个函数,当它是时
const submit = useSubmit()
function action({ request }) {
is this where i do my POST api call?
}
async function handleClick(event) {
await createCart(id, amount)
}
Run Code Online (Sandbox Code Playgroud)
似乎找不到任何文档告诉您如何执行此操作?