MY ChainList.sol-Code
pragma solidity ^0.4.23;
contract ChainList {
struct data {
uint ownernumber;
uint id;
}
uint value;
mapping (uint256 => data) public datamatching;
function storedata (uint _ownernumber, uint _id) public {
var persondata = datamatching[value];
persondata .ownernumber = _ownernumber;
persondata. id = _id;
}
function getData(uint256 userId) returns (uint, uint){
return (datamatching[userId].ownernumber, datamatching[userId].id);
}
}
// Bereitstellungsvertrag bei der Verwendung von Migrationen
var ChainList = artifacts.require("./Migrations.sol");
module.exports = function (deployer) {
deployer.deploy(ChainList);
}
// Mein trufle.js-Code
module.exports = {
networks: {
development: {
host: "localhost",
port: 8545,
network_id: "*" // Match any network id
}
}
};
Ich habe erfolgreich eingesetzt
Compiling ./contracts/ChainList.sol...
Compiling ./contracts/Migrations.sol...
Compilation warnings encountered:
/
home/mdvenkatesh/Desktop/asset/contracts/ChainList.sol:14:5: Warning: Use of the "var" keyword is deprecated.
var persondata = datamatching[value];
^-------------^
,/home/mdvenkatesh/Desktop/asset/contracts/Migrations.sol:11:3: Warning: Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead.
**Running migration: 1_initial_migration.js
Deploying Migrations...
... 0x942947d411cc40c214ee717f12a8626033aea99b9db0cfda2189a8c214c0d068
Migrations: 0x4d838fd69456fcb2c4c49b1b05c8ae7b7205cde5
Saving successful migration to network...
... 0x20659b7fdf1ac7c4a1899be68938297b5fb1cae318024c61eee7886d007d134d
Saving artifacts...
Running migration: 2_deploy_contracts.js
Replacing Migrations...
... 0xe287e9ccbe891349ca0a2b1bac64a1291558b3817a6689431bf88721122eb7c1
Migrations: 0xcc3979c6af9f5003445f26e5c1dfdc140bba29c5
Saving successful migration to network...
... 0x2a3b60f8cf3571ef12bb81ea5c80d22b6e2febae8e38f2dd0c05e0f147137305
Saving artifacts...**
Jetzt versuche ich, mit Trüffel zu intract, ich erhalte den folgenden Fehler
ChainList.deployed().then(function(instance){app= instance });
Error: ChainList has not been deployed to detected network (network/artifact mismatch)
at /usr/lib/node_modules/truffle/build/webpack:/packages/truffle-contract/contract.js:454:1
Ich glaube, ich habe alle Schritte befolgt, aber ich weiß nicht, was schief gelaufen ist. Bitte helfen Sie mir
Sie haben Ihre Bereitstellungsskripts durcheinander gebracht. Am Ende sollten Sie 2 Dateien in Ihrem /migrations/
Ordner haben:
1_initial_migration.js
var Migrations = artifacts.require("./Migrations.sol");
module.exports = function(deployer) {
deployer.deploy(Migrations);
};
2_deploy_contracts.js
var ChainList = artifacts.require("/path/to/ChainList.sol");
module.exports = function (deployer) {
deployer.deploy(ChainList);
}
In Ihrem Beispiel haben Sie die Migrationsvariablen in „ChainList“ geändert, zeigen aber immer noch auf ./Migrations.sol
. Ändern Sie dies einfach so, dass es stattdessen auf Ihre Vertragsdatei verweist.
Kaki Meister der Zeit
RD