Ripple Inc., a startup behind the XRP cryptocurrency, agreed to invest up to $50 million in MoneyGram International Inc. in a deal that stands to rank among the first crypto-based company investments in a major U.S. publicly listed firm.

Ripple agreed to buy $30 million worth of MoneyGram shares and warrants to buy stock at $4.10 a share, nearly triple the Monday closing price of $1.45 a share. The deal includes additional warrants for up to $20 million worth of additional newly issued stock, also at $4.10 a share, over the...