golang 代码

    //签名信息生成hash
    hash := solsha3.SoliditySHA3(
        []string{"address", "uint256"},
        // values
        []interface{}{
            "xxxxx", //钱包地址
            "100000",                          //金额
        },
    )

    privateKey, _ := crypto.HexToECDSA("私钥")
    signature, _ := crypto.Sign(hash, privateKey)
    signature[64] += 27
    keccak256Hash := hexutil.Encode(signature)
    fmt.Println(keccak256Hash)
   

solidity代码

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.10;

import "@openzeppelin/contracts/utils/cryptography/SignatureChecker.sol";

contract Sign  {
 
    event IsValidSignatureNow(address indexed owner, bytes32 hash, bytes signature, bool bo);
    address owner = 0xxxxxxxxx;

    //验证
    function verification(uint256 _amount, bytes calldata signature)
        external
        returns (bool)
    {
        bytes32 hash = keccak256(abi.encodePacked(msg.sender, _amount));
        bool b = _isValidSignatureNow(owner, hash, signature);
        return b;
    }

    function _isValidSignatureNow(
        address signer,
        bytes32 hash,
        bytes calldata signature
    ) private returns (bool){

        bool bo = SignatureChecker.isValidSignatureNow(signer, hash, signature);
        emit IsValidSignatureNow(signer, hash, signature, bo);
        return bo;
    }

}