How to use @aeternity/aepp-sdk - 9 common examples

To help you get started, we’ve selected a few @aeternity/aepp-sdk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aeternity / aepp-aeproject-js / packages / aeproject-utils / utils / contract-utils.js View on Github external
*  purpose with or without fee is hereby granted, provided that the above
 *  copyright notice and this permission notice appear in all copies.
 *
 *  THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
 *  REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
 *  AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
 *  INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
 *  LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
 *  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 *  PERFORMANCE OF THIS SOFTWARE.
 */

require = require('esm')(module /*, options */) // use to handle es6 import/export

const AeSDK = require('@aeternity/aepp-sdk');
const Crypto = AeSDK.Crypto;
const toBytes = require('@aeternity/aepp-sdk/es/utils/bytes').toBytes;

function keyToHex (publicKey) {
    let byteArray = Crypto.decodeBase58Check(publicKey.split('_')[1]);
    let asHex = '#' + byteArray.toString('hex');
    return asHex;
}

const isKeyPair = (k) => {
    if (k == null) {
        return false
    }
    if (typeof k != 'object') {
        return false
    }
github aeternity / aepp-aeproject-js / packages / aeproject-utils / utils / aeproject-utils.js View on Github external
require = require('esm')(module /*, options */) // use to handle es6 import/export 
let axios = require('axios');
const fs = require('fs');
const path = require('path')
const AeSDK = require('@aeternity/aepp-sdk');
const Universal = AeSDK.Universal;
let rgx = /^include\s+\"([\d\w\/\.\-\_]+)\"/gmi;
let dependencyPathRgx = /"([\d\w\/\.\-\_]+)\"/gmi;
const mainContractsPathRgx = /.*\//g;
let match;

const config = require('../../aeproject-config/config/config.json');
const {
    printError
} = require('./fs-utils')

const {
    spawn,
    exec
} = require('promisify-child-process');

const COMPILER_URL_POSTFIX = '/compile';
github aeternity / aepp-aeproject-js / cli-commands / forgae-init / artifacts / exampleTests.js View on Github external
* ISC License (ISC)
 * Copyright (c) 2018 aeternity developers
 *
 *  Permission to use, copy, modify, and/or distribute this software for any
 *  purpose with or without fee is hereby granted, provided that the above
 *  copyright notice and this permission notice appear in all copies.
 *
 *  THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
 *  REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
 *  AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
 *  INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
 *  LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
 *  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 *  PERFORMANCE OF THIS SOFTWARE.
 */
const Ae = require('@aeternity/aepp-sdk').Universal;
const fs = require('fs');
const path = require('path');

const config = {
    host: "http://localhost:3001/",
    internalHost: "http://localhost:3001/internal/",
    gas: 200000,
    ttl: 55,
    compilerUrl: 'https://compiler.aepps.com' 
    // compilerUrl: 'http://localhost:3080'
}

let contractPath = path.resolve(__dirname, './../contracts/ExampleContract.aes');
let contractSource = fs.readFileSync(contractPath, 'utf8');

describe('Example Contract', () => {
github aeternity / aepp-aeproject-js / packages / forgae-utils / utils / forgae-utils.js View on Github external
require = require('esm')(module /*, options */) // use to handle es6 import/export 
const AeSDK = require('@aeternity/aepp-sdk');
const Universal = AeSDK.Universal;
const ContractCompilerAPI = AeSDK.ContractCompilerAPI;

const config = require('forgae-config');
const {
    printError
} = require('./fs-utils')

const {
    spawn
} = require('promisify-child-process');

const getClient = async function (network, keypair = config.keypair) {
    let client;
    let internalUrl = network.url;

    if (network.url.includes("localhost")) {
github aeternity / aepp-aeproject-js / packages / forgae-utils / utils / forgae-utils.js View on Github external
require = require('esm')(module /*, options */) // use to handle es6 import/export 
const AeSDK = require('@aeternity/aepp-sdk');
const Universal = AeSDK.Universal;
const ContractCompilerAPI = AeSDK.ContractCompilerAPI;

const config = require('forgae-config');
const {
    printError
} = require('./fs-utils')

const {
    spawn
} = require('promisify-child-process');

const getClient = async function (network, keypair = config.keypair) {
    let client;
    let internalUrl = network.url;

    if (network.url.includes("localhost")) {
        internalUrl = internalUrl + "/internal"
github aeternity / aepp-aeproject-js / packages / aeproject-cli / aeproject-init / artifacts / shape / shapeDeployTemplate.js View on Github external
* ISC License (ISC)
 * Copyright (c) 2018 aeternity developers
 *
 *  Permission to use, copy, modify, and/or distribute this software for any
 *  purpose with or without fee is hereby granted, provided that the above
 *  copyright notice and this permission notice appear in all copies.
 *
 *  THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
 *  REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
 *  AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
 *  INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
 *  LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
 *  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 *  PERFORMANCE OF THIS SOFTWARE.
 */
const Ae = require('@aeternity/aepp-sdk').Universal;
const Deployer = require('aeproject-lib').Deployer;
const gasLimit = 1000000;

const deploy = async (network, privateKey) => {
	let deployer = new Deployer(network, privateKey)

	let result = await deployer.deploy("./contracts/ToDoManager.aes")
};

module.exports = {
	deploy
};
github aeternity / aepp-aeproject-js / cli-commands / aeproject-deploy / deploy.js View on Github external
const fs = require('fs');
const defaultDeploymentFilePath = `deployment/deploy.js`;
const AeSDK = require('@aeternity/aepp-sdk');
const Crypto = AeSDK.Crypto;
const path = require('path');

const verifyDeploymentFile = (deploymentFile) => {
	if (!fs.existsSync(deploymentFile)) {
		throw new Error(`${deploymentFile} file not found. Probably you've not initialized aeproject. Please run aeproject init first.`)
	}
};

const getDeployMethod = (deploymentFilePath) => {
	const _deploymentFilePath = (deploymentFilePath) ? deploymentFilePath : defaultDeploymentFilePath;
	verifyDeploymentFile(_deploymentFilePath);

	const deploymentFile = path.resolve(process.cwd(),_deploymentFilePath);
	const deployModule = require(deploymentFile);

	return deployModule.deploy;
github aeternity / aepp-aeproject-js / packages / aeproject-utils / utils / aeproject-utils.js View on Github external
await handleApiError(async () => {
        client = await Universal({
            url: network.url,
            internalUrl,
            accounts: [AeSDK.MemoryAccount({
                keypair
            })],
            nativeMode: true,
            networkId: network.networkId,
            compilerUrl: network.compilerUrl
        })
    });
github aeternity / aepp-aeproject-js / packages / aeproject-utils / utils / contract-utils.js View on Github external
function decodedHexAddressToPublicAddress (hexAddress) {

    const publicKey = Crypto.aeEncodeKey(toBytes(hexAddress, true));

    return publicKey;
}