GOST is a protocol for executing cross-chain confirmations of events between the GoChain and Ethereum blockchains. By leveraging the trust in GoChain's network of reputable signers, contracts deployed on GoChain can securely and confidently confirm events from Ethereum logs, and vice-versa. This simple primitive unlocks powerful interoperability which can be used to build more complex solutions, like cross-chain token transfers of ERC20 and GO20 tokens.
This project is still in development.
- Alpha (devnets)
- Beta (testnets)
- Production (mainnets)
The GOST protocol relies on GoChain's network of reputable signers to
monitor and manage a Confirmations
contract on each network. Users
(humans or other contracts) request confirmation of events by
specifying block number, log index, and an event hash - which
uniquely identifies a particular event. The GoChain signers monitor
for requested events, and once the block has been confirmed as canonical
they vote to confirm an event as either valid or invalid with
majority consensus.
The IConfirmations
interface defines the public set of functions available
to users, and the Confirmations
contract implements and extends the set
with administrative functions. Event hashes are content based identifiers
derived from the source contract address which emitted the event and the
event parameters (topics and data).
// Event hash pseudocode. Note that the first topic will be the event ID.
hash = keccak256(abi.encode(source, topics..., data))
This allows contracts to not only confirm a particular event, but also to operate on the values of the event's parameters. In the case of token transfers, the event can specify the amount and recipient address for the receiving contract code to use.
One application of cross-chain event confirmations is the ability to manage
cross-chain token transfers. By confirming events emitted when tokens are
frozen or burned on one network, we can securely unfreeze or mint tokens on
the other network. The Transfers
contract defines a GOSTTransfer
event,
and provides a function to compute event hashes:
event GOSTTransfer(address indexed addr, uint amount);
// Compute the event hash for a GOSTTransfer event from the source contract.
function transferEventHash(address addr, uint amount) public view returns (bytes32) {
return keccak256(abi.encode(transferSourceContract, eventID, addr, amount));
}
The Custody
and Proxy
contracts use these building blocks to securely transfer
tokens back and forth between networks.
The Custody
contract deployed to the origin network (where the ERC20
/GO20
token
is deployed) and the Proxy
contract deployed to the other network both emit and
confirm each others' GOSTTransfer
events. The custody contract holds locked
tokens which have been sent to the proxy network, and only unlocks them when
return transfer events from the proxy network are confirmed. Similarly, the proxy
contract mints tokens when incoming transfers are confirmed and burns them when
outgoing transfers are initiated.
How to transfer tokens from their origin network to the proxy network:
token.approve()
: Approve the custody contract as a spender for the amount being transferred.custody.proxyTransfer()
: Initiate the transfer by freezing tokens in the custody contract and emitting aGOSTTransfer
event.proxyConfirmations.request()
: Request confirmation of the event and deposit funds to cover confirmation gas fees.proxyConfirmations.status()
: Wait for confirmation from the signers that the event is valid (statusConfirmed
).proxy.claimTransfer()
: Claim the confirmed transfer to receive minted tokens.
How to transfer tokens from the proxy network back to the origin network:
proxy.originTransfer()
: Initiate the transfer by burning tokens in the proxy contract and emitting aGOSTTransfer
event.originConfirmations.request()
: Request confirmations of the event and deposit funds to cover confirmations gas fees.originConfirmations.status()
: Wait for confirmations from the signers that the event is valid (statusConfirmed
).origin.claimTransfer()
: Claim the confirmed transfer to receive unlocked tokens.
TODO confirmations TODO proxy and custody
TODO deployment steps for proxy and custody contracts (just link command or script?)
Contract addresses for the Confirmations
contracts manages by the GoChain signers:
Network | Address |
---|---|
GoChain | TBD |
Ethereum | TBD |
Network | Address |
---|---|
GoChain | TBD |
Ropsten | TBD |
Contract addresses for cross-chain tokens:
Token | Origin | Address | Custody | Proxy |
---|---|---|---|---|
SampleToken | Ethereum | 0x0 | 0x1 | 0x2 |