[Solved] Can't interact with smart contracts through my own node ran with docker

Hello guys,

I set up a testnet node and a compiler node through docker. The command that I use for the testnet node is the following:
docker run -d --restart=always --name ae-testnet -p 3013:3013 -p 3015:3015 -v ~/.aeternity/myaeternity.yaml:/home/aeternity/.aeternity/aeternity/aeternity.yaml -v myaedb:/home/aeternity/node/data/mnesia aeternity/aeternity

and this is my configuration file:

chain:
    persist: true

peers:
    # UAT
    - aenode://pp_QU9CvhAQH56a2kA15tCnWPRJ2srMJW8ZmfbbFTAy7eG4o16Bf@52.10.46.160:3015
    - aenode://pp_2vhFb3HtHd1S7ynbpbFnEdph1tnDXFSfu4NGtq46S2eM5HCdbC@18.195.109.60:3015
    - aenode://pp_27xmgQ4N1E3QwHyoutLtZsHW5DSW4zneQJ3CxT5JbUejxtFuAu@13.250.162.250:3015
    - aenode://pp_DMLqy7Zuhoxe2FzpydyQTgwCJ52wouzxtHWsPGo51XDcxc5c8@13.53.161.215:3015

fork_management:
    network_id: ae_uat

I’m trying to interact with the following contract using javascript SDK:

contract Identity =
  type state = ()
  function main(x : int) = x + 1
  function go(who : address) = who

This is how I interact with the contract:

const fs = require('fs')
const contractFile = fs.readFileSync('./identity.aes');
const source = contractFile.toString();

const { Universal: Ae } = require('@Albert/aepp-sdk');
console.log(source);

Ae({ url: 'mynode:3013', internalUrl: 'mynode:3013', compilerUrl: 'mynode:3080', keypair: {
  publicKey: 'mypublickey',
  secretKey: 'mysecretkey,
}}).then(async (ae) => {
  ae.height().then(height => {
    console.log('Current Block', height);
  });

  const contract = await ae.getContractInstance(source, { contractAddress: 'ct_2XL4hnKxNXV6BAEq7Q6Dp7dP7RRqxrntY34M5DnZ4kceETUNg7' }).catch(err => { console.log(err); });
  const result = await contract.call('main', ['34'], { callStatic: true });
  console.log(result);
  const decoded = await result.decode();
  console.log(decoded);
})

SDK version is 3.1.0.
Docker image is latest.

So if I connect to https://sdk-testnet.aepps.com/ instead of my own node it works ok. When I use my node, it successfully connects and gets the blockchain height but it is unable to interact with the contract and I get the following error:
Error: While calling dryRunTxs (body), Request failed with status code 404

I believe it is something with configuration file or the way I run the container.

Appreciate your support!

1 Like

A support for this issue would be highly appreciated.

Hello @weidex_team

you will have to enable the debug/internal endpoints in your http api:

http:
    internal:
        debug_endpoints: true
        listen_address: 0.0.0.0
        port: 3113

they are disabled by default since release 1.3.0 as not every node should have them public.

Hope this solves your issue :slight_smile:

1 Like

Additionally you would have to foreward port 3113 in docker and use this as internal url when you initialize your node.

1 Like

Works perfectly, thanks @philipp.chain :bowing_man:

1 Like