contract FungibleToken =
public entrypoint transfer : (address, int) => bool
public entrypoint transfer_from : (address, address, int) => bool
contract ExchangeContract =
record state = {
receiving_token : FungibleToken,
sending_token : FungibleToken,
rate : int}
public stateful entrypoint init(receiving_token: FungibleToken, sending_token: FungibleToken, rate: int) = {
receiving_token = receiving_token,
sending_token = sending_token,
rate = rate}
public entrypoint exchange(value: int) : bool =
state.receiving_token.transfer_from(Call.caller, Contract.address, value)
state.sending_token.transfer(Call.caller, value * state.rate)
true
The above contract code for TUTORIAL: Simple Fungible Token Exchange Smart Contract - Part 2 is giving the error below when deploying
Error: Http request for https://compiler.aepps.com/encode-calldata failed with status code 403. Status: . Error data: {"reason":"Type errors\nUnbound variable undefined at line 21, column 59\n\nUnbound variable undefined at line 21, column 49\n\nUnbound variable undefined at line 21, column 39\n"}
2 Likes
@emmanueljet Can you share your deployment script, it could be of how you pass the arguments to the init function when deploying the smart contract.
const Deployer = require('forgae-lib').Deployer;
const deploy = async (network, privateKey, compiler, networkId) => {
const deployer = new Deployer(network, privateKey, compiler, networkId)
const receivingTokenAddress = "0xae0c896bb57e68fa877e44c334967c0933aba3ad4bd4190f746620efaf786af9"
const sendingTokenAddress = "0x44a9998bc8914ab687f40c600fa4e23663a69d50df35e2c44cd795eee261a3e8"
const rate = 2
await deployer.deploy("./contracts/ExchangeContract.aes", undefined, `(${receivingTokenAddress}, ${sendingTokenAddress}, ${rate})`)
};
module.exports = {
deploy
};
Great tutorial, thank you, that is exactly what I was searching for. I’ve always had a dream to have my own cryptocurrency exchange. Now I’m trying to get as much knowledge as I can in this niche. That is why I find such a thread very important for such people as me. By the way that is very much money needed to open my own cryptocurrency exchange, but I strongly believe that one day I will achieve this goal. By the way, I pay attention very often on one very good crypto exchange with no fees. Visit site to find it and to understand why it is better.
1 Like