How to use truffle-contract - 10 common examples

To help you get started, we’ve selected a few truffle-contract 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 Soltsice / Soltsice / src / lib / W3 / _DBrainToken.ts View on Github external
constructor(web3: Web3, from: Web3.address, multisig: Web3.address, deployedContractAddress?: Web3.address) {
        if (!this.isValidAddress(from)) {
            throw 'Invalid from address';
        }
        if (!this.isValidAddress(multisig)) {
            throw 'Invalid multisig address';
        }
        if (deployedContractAddress && !this.isValidAddress(deployedContractAddress)) {
            throw 'Invalid deployed contract address';
        }

        this.web3 = web3;

        let tokenArtifacts = require('../../contracts/DBrainToken.json');

        let Token = contract(tokenArtifacts);
        Token.setProvider(web3.currentProvider);
        Token.defaults({
            from: from,
            gas: 4712388,
            gasPrice: 100000000000,
            value: 0
        });

        // console.log('TOKEN', JSON.stringify(Token));

        let instance = new Promise((resolve, reject) => {
            if (this.isValidAddress(deployedContractAddress)) {
                console.log('DEPLOYED');
                this.address = deployedContractAddress!;
                this.instance = Token.at(this.address).then((inst) => {
                    resolve(inst);
github kierenh / vue-dark-chocolate / app / app.js View on Github external
console.log('This is mainnet')
        break
      case '27666':
        console.log('This is the development-no-data-seed network')
        break
      default:
        console.log('This is an unknown network.')
        break
    }
  })

  const ProxiedWeb3 = require("./api/ProxiedWeb3.js");
  window.proxiedWeb3 = new ProxiedWeb3(web3);

  // TradeRegister is our usable smart contract abstraction, which we'll use through the code below.
  var TradeRegister = contract(traderegister_artifacts)

  // Bootstrap the TradeRegister abstraction for Use.
  TradeRegister.setProvider(web3.currentProvider)

  const apis = {
    web3,
    proxiedWeb3,
    trade: new Trade(web3, TradeRegister),
  }

  var store = new Store(apis)
  var router = new VueRouter({
    linkActiveClass: 'active',
    linkExactActiveClass: 'active',
    routes: Routes.routes,
  })
github anshulshah96 / CrowdBank / app / javascripts / verify.js View on Github external
// Import the page's CSS. Webpack will know what to do with it.
// import "../stylesheets/app.css";

// Import libraries we need.
import { default as Web3} from 'web3';
import { default as contract } from 'truffle-contract';

import bank_artifacts from '../../build/contracts/Mortgage.json';

var Mortgage = contract(bank_artifacts);
var account;
var wtoE;
var GAS_AMOUNT = 90000000;
var BASE_URL = 'https://sh3r.tech/files/';
var md5 = require('md5');

window.verifyData = function() {
  var hash = $('#file-hash').val();
  var link = BASE_URL + hash + '.pdf';
  document.getElementById('pdfRenderer').src = link;
  Mortgage.deployed().then(function(contractInstance) {
    contractInstance.getOwnerCount.call(hash).then(function(result) {
      $('#mortgage-owner-list').empty();
      if(result.valueOf() == 0)
      {
         $('#mortgage-owner-list').append('<li class="list-group-item">No Owners Found! Be careful!</li>');
github anshulshah96 / CrowdBank / app / javascripts / borrower.js View on Github external
// Import the page's CSS. Webpack will know what to do with it.
// import "../stylesheets/app.css";

// Import libraries we need.
import { default as Web3} from 'web3';
import { default as contract } from 'truffle-contract';

import bank_artifacts from '../../build/contracts/CrowdBank.json';
import bank_artifacts2 from '../../build/contracts/Mortgage.json';

var CrowdBank = contract(bank_artifacts);
var Mortgage = contract(bank_artifacts2);
var account;
var wtoE;
var GAS_AMOUNT = 90000000;

var LOANSTATE = {
  0 : "ACCEPTING",
  1 : "LOCKED",
  2 : "COMPLETED SUCCESSFUL",
  3 : "COMPLETION FAILED"
}
var LOANSTATECLASS = {
  0 : "primary",
  1 : "info",
  2 : "success",
  3 : "danger"
github alice-si / contracts / app / javascripts / app.js View on Github external
// Import libraries we need.
import { default as Web3} from 'web3';
import { default as contract } from 'truffle-contract'

// Import our contract artifacts and turn them into usable abstractions.
import alice_token_artifacts from '../../build/contracts/AliceToken.json';
import wallet_artifacts from '../../build/contracts/DonationWallet.json';
import project_with_bonds_artifacts from '../../build/contracts/ProjectWithBonds.json';
import catalog_artifacts from '../../build/contracts/ProjectCatalog.json';
import impact_registry_artifacts from '../../build/contracts/ImpactRegistry.json';
import linker_artifacts from '../../build/contracts/FlexibleImpactLinker.json';
import investor_artifacts from '../../build/contracts/InvestmentWallet.json';
import coupon_artifacts from '../../build/contracts/Coupon.json';

// MetaCoin is our usable abstraction, which we'll use through the code below.
var AliceToken = contract(alice_token_artifacts);
var Wallet = contract(wallet_artifacts);
var ProjectWithBonds = contract(project_with_bonds_artifacts);
var Catalog = contract(catalog_artifacts);
var ImpactRegistry = contract(impact_registry_artifacts);
var Linker = contract(linker_artifacts);
var Investor = contract(investor_artifacts);
var Coupon = contract(coupon_artifacts);

const PROJECT_NAME = "DEMO_PROJECT";

var accounts;
var aliceAccount;
var donor1Account;
var donor2Account;
var beneficiaryAccount;
var validatorAccount;
github alice-si / monorepo / packages / contracts / app / javascripts / app.js View on Github external
// Import libraries we need.
import { default as Web3} from 'web3';
import { default as contract } from 'truffle-contract'

// Import our contract artifacts and turn them into usable abstractions.
import alice_token_artifacts from '../../build/contracts/AliceToken.json';
import wallet_artifacts from '../../build/contracts/DonationWallet.json';
import project_with_bonds_artifacts from '../../build/contracts/ProjectWithBonds.json';
import catalog_artifacts from '../../build/contracts/ProjectCatalog.json';
import impact_registry_artifacts from '../../build/contracts/ImpactRegistry.json';
import linker_artifacts from '../../build/contracts/FlexibleImpactLinker.json';
import investor_artifacts from '../../build/contracts/InvestmentWallet.json';
import coupon_artifacts from '../../build/contracts/Coupon.json';

// MetaCoin is our usable abstraction, which we'll use through the code below.
var AliceToken = contract(alice_token_artifacts);
var Wallet = contract(wallet_artifacts);
var ProjectWithBonds = contract(project_with_bonds_artifacts);
var Catalog = contract(catalog_artifacts);
var ImpactRegistry = contract(impact_registry_artifacts);
var Linker = contract(linker_artifacts);
var Investor = contract(investor_artifacts);
var Coupon = contract(coupon_artifacts);

const PROJECT_NAME = "DEMO_PROJECT";

var accounts;
var aliceAccount;
var donor1Account;
var donor2Account;
var beneficiaryAccount;
var validatorAccount;
github alice-si / contracts / app / javascripts / app.js View on Github external
import { default as Web3} from 'web3';
import { default as contract } from 'truffle-contract'

// Import our contract artifacts and turn them into usable abstractions.
import alice_token_artifacts from '../../build/contracts/AliceToken.json';
import wallet_artifacts from '../../build/contracts/DonationWallet.json';
import project_with_bonds_artifacts from '../../build/contracts/ProjectWithBonds.json';
import catalog_artifacts from '../../build/contracts/ProjectCatalog.json';
import impact_registry_artifacts from '../../build/contracts/ImpactRegistry.json';
import linker_artifacts from '../../build/contracts/FlexibleImpactLinker.json';
import investor_artifacts from '../../build/contracts/InvestmentWallet.json';
import coupon_artifacts from '../../build/contracts/Coupon.json';

// MetaCoin is our usable abstraction, which we'll use through the code below.
var AliceToken = contract(alice_token_artifacts);
var Wallet = contract(wallet_artifacts);
var ProjectWithBonds = contract(project_with_bonds_artifacts);
var Catalog = contract(catalog_artifacts);
var ImpactRegistry = contract(impact_registry_artifacts);
var Linker = contract(linker_artifacts);
var Investor = contract(investor_artifacts);
var Coupon = contract(coupon_artifacts);

const PROJECT_NAME = "DEMO_PROJECT";

var accounts;
var aliceAccount;
var donor1Account;
var donor2Account;
var beneficiaryAccount;
var validatorAccount;
github alice-si / monorepo / packages / contracts / app / javascripts / app.js View on Github external
import { default as Web3} from 'web3';
import { default as contract } from 'truffle-contract'

// Import our contract artifacts and turn them into usable abstractions.
import alice_token_artifacts from '../../build/contracts/AliceToken.json';
import wallet_artifacts from '../../build/contracts/DonationWallet.json';
import project_with_bonds_artifacts from '../../build/contracts/ProjectWithBonds.json';
import catalog_artifacts from '../../build/contracts/ProjectCatalog.json';
import impact_registry_artifacts from '../../build/contracts/ImpactRegistry.json';
import linker_artifacts from '../../build/contracts/FlexibleImpactLinker.json';
import investor_artifacts from '../../build/contracts/InvestmentWallet.json';
import coupon_artifacts from '../../build/contracts/Coupon.json';

// MetaCoin is our usable abstraction, which we'll use through the code below.
var AliceToken = contract(alice_token_artifacts);
var Wallet = contract(wallet_artifacts);
var ProjectWithBonds = contract(project_with_bonds_artifacts);
var Catalog = contract(catalog_artifacts);
var ImpactRegistry = contract(impact_registry_artifacts);
var Linker = contract(linker_artifacts);
var Investor = contract(investor_artifacts);
var Coupon = contract(coupon_artifacts);

const PROJECT_NAME = "DEMO_PROJECT";

var accounts;
var aliceAccount;
var donor1Account;
var donor2Account;
var beneficiaryAccount;
var validatorAccount;
github alice-si / contracts / app / javascripts / app.js View on Github external
import alice_token_artifacts from '../../build/contracts/AliceToken.json';
import wallet_artifacts from '../../build/contracts/DonationWallet.json';
import project_with_bonds_artifacts from '../../build/contracts/ProjectWithBonds.json';
import catalog_artifacts from '../../build/contracts/ProjectCatalog.json';
import impact_registry_artifacts from '../../build/contracts/ImpactRegistry.json';
import linker_artifacts from '../../build/contracts/FlexibleImpactLinker.json';
import investor_artifacts from '../../build/contracts/InvestmentWallet.json';
import coupon_artifacts from '../../build/contracts/Coupon.json';

// MetaCoin is our usable abstraction, which we'll use through the code below.
var AliceToken = contract(alice_token_artifacts);
var Wallet = contract(wallet_artifacts);
var ProjectWithBonds = contract(project_with_bonds_artifacts);
var Catalog = contract(catalog_artifacts);
var ImpactRegistry = contract(impact_registry_artifacts);
var Linker = contract(linker_artifacts);
var Investor = contract(investor_artifacts);
var Coupon = contract(coupon_artifacts);

const PROJECT_NAME = "DEMO_PROJECT";

var accounts;
var aliceAccount;
var donor1Account;
var donor2Account;
var beneficiaryAccount;
var validatorAccount;

var TokenContract;
var CharityContract;
var ImpactContract;
var CatalogContract;
github yhuag / The-Neon-Network-ECoupons-On-Blockchain / app / javascripts / app.js View on Github external
// Import the page's CSS. Webpack will know what to do with it.
import "../stylesheets/app.css";

// Import libraries we need.
import { default as Web3 } from 'web3';
import { default as contract } from 'truffle-contract'

// Import our contract artifacts and turn them into usable abstractions.
import Market_artifacts from '../../build/contracts/Market.json'
import Coupon_artifacts from '../../build/contracts/Coupon.json'

// Market is our usable abstraction, which we'll use through the code below.
var Market = contract(Market_artifacts);
var Coupon = contract(Coupon_artifacts);

var market_contract_address_rinkeby = "0x3a4b4259140988baAF9De41E95423052D9c0300E";
var using_localhost = false;
let market;

// The following code is simple to show off interacting with your contracts.
// As your needs grow you will likely need to change its form and structure.
// For application bootstrapping, check out window.addEventListener below.
var accounts;
var account;

window.App = {
  start: function () {
    var self = this;
    var LOCALHOST_URL = 'http://localhost:8545';

truffle-contract

A better contract abstraction for Ethereum (formerly EtherPudding)

MIT
Latest version published 5 years ago

Package Health Score

53 / 100
Full package analysis

Popular truffle-contract functions