0

トークンを購入する処理に、返金機能をつけています

pragma solidity ^0.5.0;

import 'https://github.com/OpenZeppelin/openzeppelin-solidity/contracts/token/ERC721/ERC721Full.sol';
import "https://github.com/OpenZeppelin/openzeppelin-solidity/contracts/token/ERC721/ERC721Mintable.sol";
import "https://github.com/OpenZeppelin/openzeppelin-solidity/contracts/token/ERC721/ERC721MetadataMintable.sol";

import "https://github.com/OpenZeppelin/openzeppelin-solidity/contracts/ownership/Ownable.sol";

contract Ticketing is ERC721Full, ERC721Mintable, ERC721MetadataMintable, Ownable {

    uint256 public constant ticket_price = 300;

    event Ticketing(string _symbol, address _msg_sender, uint256 _token_id);
    event TicketingCancel(string _symbol, address _msg_sender, uint256 _token_id);

    uint256 internal next_token_id = 0;
    uint256 private constant e2w = 10**18;
    uint256 private constant price = ticket_price * e2w;

    constructor() ERC721Full("Ticketing", "Ticketing") public {
    }

    function() payable external{
        require(msg.value == price);

        for(uint256 token_id = 0; token_id < this.totalSupply(); token_id++) {
            if (this.ownerOf(token_id) == this.owner()) {
                this.transferFrom(address(this), msg.sender, token_id);
                emit Ticketing(this.symbol(), msg.sender, token_id);
                break;
            }
        }
    }

    function cancel(uint256 _token_id) external returns(uint256) {
        require(this.ownerOf(_token_id) == msg.sender);

        this.transferFrom(msg.sender, this.owner(), _token_id);
        _withdraw(msg.sender);
        emit TicketingCancel(this.symbol(), msg.sender, _token_id);
    }

    function _withdraw(address _address) private returns(uint256) {
        _address.transfer(price);
    }

    function mint(string calldata _message) external returns (uint256) {
        require(msg.sender == this.owner());

        uint256 token_id = next_token_id;
        _mint(msg.sender, token_id);
        next_token_id = next_token_id.add(1);
        return token_id;
    }

    function burn(uint256 _token_id) external {
        require(msg.sender == this.owner());

        super._burn(msg.sender, _token_id);
    }
}

エラーは_withdrawの箇所で以下の通り

TypeError: Member "transfer" not found or not visible after argument-dependent lookup in address.
_address.transfer(price);
^---------------^

スマートコントラクトからの正しい送金処理をご教示いただけないでしょうか

1 件の回答 1

1

自己解決しました


function _withdraw(address payable _address) internal returns (uint256) {
    _address.transfer(price);
}

internalを付与しました

ご参考になれば幸いです

この質問に回答するには、ログインする必要があります。

求めていた回答ではありませんか? のタグが付いた他の質問を参照する。