-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* added GOSH GitHub Sync section to Integration
- Loading branch information
Showing
110 changed files
with
40,650 additions
and
1,949 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,299 @@ | ||
# **GOSH Ethereum L2** | ||
|
||
|
||
## **Integration with GOSH L2** | ||
|
||
|
||
### **Introduction** | ||
|
||
Endpoint for use with [Ever-SDK](https://docs.everos.dev/ever-sdk/) | ||
|
||
``` | ||
network main: https://network.gosh.sh | ||
``` | ||
|
||
The contract [**Profile**](https://github.com/gosh-sh/gosh/blob/dev/v6_x/v6.1.0/contracts/profile.sol) (1) is deployed for each user when registering with GOSH. | ||
{ .annotate } | ||
|
||
1. The ABI can be obtained by [link](https://github.com/gosh-sh/gosh/blob/dev/v6_x/v6.1.0/contracts/profile.abi.json) | ||
|
||
To get its address, you need to call the method: | ||
|
||
``` | ||
getProfileAddr(string name) returns(address) | ||
``` | ||
|
||
where: | ||
|
||
`name` - user's name | ||
{ .ml-params } | ||
|
||
from the contract [**VersionController**](https://github.com/gosh-sh/gosh/blob/dev/v6_x/v6.1.0/contracts/gosh/versioncontroller.sol), (1) | ||
{ .annotate } | ||
|
||
1. is a contract version manager used when upgrading GOSH smart contracts | ||
|
||
address (permanent) | ||
``` | ||
0:5cbbbce41fc4290f3d4b085ab30912831b710fa2c681f6ea227d4a22f2b304f5 | ||
``` | ||
The ABI can be obtained by [link](https://github.com/gosh-sh/gosh/blob/dev/v6_x/v6.1.0/contracts/gosh/versioncontroller.abi.json) | ||
The result is the address of the user's **Profile** contract. | ||
### **Transfer tokens** | ||
#### **from GOSH to GOSH** | ||
Before transferring to another TIP3-wallet, you need to check whether the recipient's TIP3-wallet is already deployed. | ||
To do this, you need to call the method [`getWalletAddress`](ethereum-L2.md#getting-the-users-tip3-wallet-address-using-the-users-public-key) in the **RootTokenContract**, the recipient's public key is specified. | ||
If the recipient's TIP3-wallet is not deployed, you need to call the method `transferToRecipient` in the TIP3-wallet contract **"TONTokenWallet"** (1) (from which the transfer will be made). | ||
{ .annotate } | ||
1. ABI [here](../static/TONTokenWallet.abi){:download="TONTokenWallet.abi"} | ||
``` cpp | ||
void transferToRecipient( | ||
address_opt answer_addr, | ||
Tip3Creds to, | ||
uint128 tokens, | ||
uint128 evers, | ||
uint128 keep_evers, | ||
bool deploy, | ||
uint128 return_ownership, | ||
opt<cell> notify_payload | ||
) | ||
``` | ||
|
||
where: | ||
|
||
`answer_addr` - Answer address, **(should be `null`)** | ||
`to` - Recipient credentials (pubkey + owner **(should be `null`)**) | ||
`tokens` - Amount of tokens to transfer, **(should be `0`)** | ||
`evers` - Native funds to process. For internal requests, this value is ignored and processing costs will be taken from attached value | ||
`keep_evers` - Evers to keep in destination wallet | ||
`deploy` - **(should be `true`)** then the contract will send acceptTransfer message with StateInit to also deploy new tip3 wallet (if it doesn't already exist) with the provided recipient public key and recipient internal owner | ||
`return_ownership` - Return ownership - to decrease lend ownership for the caller contract (additionally), **(should be `0`)** | ||
`notify_payload` - (optional) < Payload (arbitrary cell) - if specified, will be transmitted into dest owner's notification, **(should be `0`)** | ||
{ .ml-params } | ||
|
||
<!-- await this.run('transferToRecipient', { | ||
_answer_id: 0, | ||
answer_addr: null, | ||
to: { pubkey, owner: null }, | ||
tokens: 0, | ||
evers: BigInt(4.5 * 10 ** 9).toString(), | ||
keep_evers: BigInt(4 * 10 ** 9).toString(), | ||
deploy: true, | ||
return_ownership: 0, | ||
notify_payload: null, | ||
}) --> | ||
|
||
As a result, an empty TIP3-wallet will be deployed to the recipient. | ||
|
||
|
||
!!! Warning | ||
**It is important to wait until the contract status changes to "Аctive".** | ||
|
||
|
||
Then, for transfer the TIP3-tokens to the user, you need to call the method `transfer` in the **TONTokenWallet** contract. | ||
|
||
``` cpp | ||
void transfer( | ||
address_opt answer_addr, | ||
address to, | ||
uint128 tokens, | ||
uint128 evers, | ||
uint128 return_ownership, | ||
opt<cell> notify_payload | ||
) | ||
``` | ||
|
||
where: | ||
|
||
`answer_addr` - (опциональный) Answer address **(should be `null`)** | ||
`to` - Destination TIP3-wallet address | ||
`tokens` - Amount of tokens to transfer | ||
`evers` - Native funds to process. For internal requests, this value is ignored and processing costs will be taken from attached value | ||
`return_ownership` - Return ownership - to decrease lend ownership provided for the caller contract (additionally) **(should be `0`)** | ||
`notify_payload` - Payload (arbitrary cell) - if specified, will be transmitted into dest owner's notification **(should be `null`)** | ||
{ .ml-params } | ||
|
||
<!-- | ||
`await this.run('transfer', { | ||
_answer_id: 0, | ||
answer_addr: null, | ||
to: address, | ||
tokens: amount.toString(), | ||
evers: BigInt(4 * 10 ** 9).toString(), | ||
return_ownership: 0, | ||
notify_payload: null, | ||
})` --> | ||
|
||
#### **from Ethereum to GOSH** | ||
|
||
|
||
For transfer `ETH` to GOSH, you need to call the method `deposit` in the **ELOCK** (1) contract, with attached value (the number of `ETH`, that will be transferred to GOSH). | ||
{ .annotate } | ||
|
||
1. is a GOSH L2 smart contract on Ethereum Blockchain. | ||
It receives deposits from users, manage withdrawals and locks user funds. ELOCK is also counting its total balance, total transaction count and stores root Merkle proofs, withdrawal smart contract code hash, etc. for L2 synchronization. | ||
|
||
address in Ethereum: | ||
``` | ||
0x135d03AF576633B0C99FB9F0A0c6Aa9cE8D3C67E | ||
``` | ||
ABI [here](../static/Elock.json){:download="Elock.json"} | ||
``` | ||
deposit(uint256 pubkey) public payable | ||
``` | ||
where: | ||
`pubkey` - the recipient's public key in GOSH | ||
{ .ml-params } | ||
Then it is necessary [to calculate the address of the user's TIP3-wallet in GOSH](ethereum-L2.md#getting-the-users-tip3-wallet-address-using-the-users-public-key) and wait the transfer of `WETH` tokens (wrapped `ETH`) to the received address. | ||
!!! exsample annotate "example of calling the ELock contract in Ethereum" | ||
``` cpp | ||
const elock = new data.web3.instance.eth.Contract( | ||
ELockAbi.abi, | ||
AppConfig.elockaddr, | ||
) | ||
const edata = elock.methods.deposit(data.summary.to.user.value.pubkey).encodeABI() | ||
const receipt = await data.web3.instance.eth.sendTransaction({ | ||
from: data.web3.address, | ||
to: AppConfig.elockaddr, | ||
value: data.web3.instance.utils.toWei(data.summary.from.amount, 'ether'), | ||
data: edata, | ||
gasLimit: 100000, | ||
maxPriorityFeePerGas: 25000, | ||
}) | ||
``` | ||
#### **from GOSH to Ethereum** | ||
For transfer "WETH" to Ethereum, you need to call the `burnTokens` method in the user contract **TONTokenWallet** | ||
``` cpp | ||
void burnTokens(uint128 tokens, uint256 to) | ||
``` | ||
|
||
where: | ||
|
||
`tokens` - amount WETH, which will be transferred to Ethereum | ||
`to` - the address of the recipient's wallet in Ethereum | ||
{ .ml-params } | ||
|
||
Then wait for the transfer of `ETH` to the recipient's wallet in Ethereum. | ||
|
||
|
||
### **Getting the TIP3-wallet address by user name** | ||
|
||
|
||
Knowing the address of the user's contract **Profile** (1) you call the method `getAccess()` in it. | ||
{ .annotate } | ||
|
||
1. The ABI can be obtained by [link](https://github.com/gosh-sh/gosh/blob/dev/v6_x/v6.1.0/contracts/profile.abi.json) | ||
|
||
|
||
``` | ||
getAccess() returns(mapping(uint256 => uint8)) | ||
``` | ||
|
||
As a result, you get a list of all the user's public keys with their numbers. | ||
|
||
!!! warning annotate "Important" | ||
It is necessary to take the zeroth pubkey from the list | ||
|
||
Then, using the received user's public key, it will be possible [to determine the address of the user's TIP3-wallet](ethereum-L2.md#getting-the-users-tip3-wallet-address-using-the-users-public-key) | ||
|
||
|
||
### **Getting the user's TIP3-wallet address using the user's public key** | ||
|
||
|
||
To do this, in the **RootTokenContract** (1) | ||
{ .annotate } | ||
|
||
1. address | ||
|
||
``` | ||
0:1792014440934b9c4024c97221b49c50bd2e2db1426b612ba4c6694b144f5e77 | ||
``` | ||
ABI [here](../static/RootTokenContract.abi){:download="RootTokenContract.abi"} | ||
calling method: | ||
``` | ||
address getWalletAddress(uint256 pubkey, address_opt owner) | ||
``` | ||
where: | ||
`pubkey` - user's public key | ||
`owner` - optional parameter, not used | ||
{ .ml-params } | ||
### **Getting a list of incoming messages of the contract** | ||
!!! example | ||
[of how to receive account messages](https://github.com/gosh-sh/gosh/blob/dev/web/src/blockchain/contract.ts#L90) | ||
!!! info | ||
[Using](https://docs.everplatform.dev/samples/graphql-samples/accounts#pagination-parameters) pagination in the SDK | ||
### **Get info about TIP3-wallet details** | ||
For get information about the TIP3-wallet in the contract **TONTokenWallet**, the `getDetails` method is called: | ||
``` | ||
details_info getDetails() | ||
``` | ||
and you get the data structure: | ||
``` | ||
struct details_info { | ||
string name; ///< Token name. | ||
string symbol; ///< Token short symbol. | ||
uint8 decimals; ///< Decimals for ui purposes. ex: balance 100 with decimals 2 will be printed as 1.00. | ||
uint128 balance; ///< Token balance of the wallet. | ||
uint128 locked; ///< Locked token balance of the wallet. | ||
uint256 root_pubkey; ///< Public key of the related RootTokenContract. | ||
address root_address; ///< Address of the related RootTokenContract. | ||
uint256 wallet_pubkey; ///< Public key of wallet owner (User id for FlexWallet). | ||
address_opt owner_address; ///< Owner contract address for internal ownership, will be 0:0..0 otherwise. | ||
opt<uint256> lend_pubkey; ///< Lend ownership pubkey. | ||
lend_owners_array lend_owners; ///< All lend ownership records of the contract. | ||
uint128 lend_balance; ///< Summarized lend balance to all targets. | ||
///< Actual active balance will be `balance - lend_balance`. | ||
opt<bind_info> binding; ///< Flex binding info. | ||
uint256 code_hash; ///< TIP3 wallet code hash to verify other wallets. | ||
uint16 code_depth; ///< TIP3 wallet code depth to verify other wallets. | ||
int8 workchain_id; ///< Workchain id. | ||
} | ||
``` |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Oops, something went wrong.