Open hui-an-yang opened 4 months ago
According to etherlink bridge repo there seem to have no support to withdraw tez from etherlink back to ghostnet. Created ticket on the repo, this ticket is currently pending depending on etherlink bridge support.
I found the contract address for the bridge on etherlink side 0xff00000000000000000000000000000000000001
here's a sample script to send 1 tez back to ghostnet. you'll need to wait 2 weeks for the xtz to appear back in your wallet though due to the "cement" period.
const { Web3 } = require('web3');
const WalletProvider = require("@truffle/hdwallet-provider");
const rpc = 'https://node.ghostnet.etherlink.com/';
const privateKey = "<wallet private key>" // input private key
const provider = new WalletProvider(privateKey, rpc);
const web3 = new Web3(provider);
// withdraw method
let abi = [
{
type: 'function',
name: 'withdraw_base58',
constant: false,
payable: true,
inputs: [{ type: 'string', name: 'target' }],
outputs: [],
},
];
const contractAddress = "0xff00000000000000000000000000000000000001"; // bridge address
const c = new web3.eth.Contract(abi, contractAddress);
const sender="0x123"; // sender address on etherlink
const recipient="tz123"; //recipient address on tezos
const withdrawAmt = 1 * 10**18; // amt in tez expressed in wei (etherlink has 18 decimals)
c.methods['withdraw_base58(string)'](recipient)
.send({ from: sender, transactionConfirmationBlocks: 2, value: withdrawAmt, type: 0 })
.on('transactionHash', function(hash){
console.log("hash:",hash);
})
.on('receipt', function(receipt){
console.log("receipt:", receipt)
})
.on('error', function(error, receipt){
console.log("error:", error)
})
.then(function(receipt){
console.log("finished");
process.exit();
}).catch(error => {
console.log(error);
process.exit();
});
currently not feasible, will look into alternative solutions in the near future
Add a test case in taquito-test-dapp that will give user instructions to transfer their etherlink tez back to ghostnet (need to explore how)