Redux Web3.js不接受常量变量为';发件人:';行动中的地址创建者
我试图将一个道具对象(redux商店中保存的合同地址)传递给动作创建者,并将该道具对象用作“发件人:”地址。但是,如果我不手动传递地址的原始字符串,我会得到一个“no from address specified” 我已经通过了简单的地址,动作创造者的作品很棒。只要我给它变量。我得到了错误Redux Web3.js不接受常量变量为';发件人:';行动中的地址创建者,redux,ethereum,redux-thunk,web3,web3js,Redux,Ethereum,Redux Thunk,Web3,Web3js,我试图将一个道具对象(redux商店中保存的合同地址)传递给动作创建者,并将该道具对象用作“发件人:”地址。但是,如果我不手动传递地址的原始字符串,我会得到一个“no from address specified” 我已经通过了简单的地址,动作创造者的作品很棒。只要我给它变量。我得到了错误 //ACTION CREATOR export const createOrgAndContract = (id) => async (dispatch, getState) => { c
//ACTION CREATOR
export const createOrgAndContract = (id) => async (dispatch, getState) => {
const account = await getState().web3connect.account;
console.log(account);
const createContract = await orgFactory.methods.createOrg(id).send({ from: `${account}` });
const contractAddress = createContract.events.orgCreated.returnValues.newAddress;
const response = await localDB.post(`/orgs`, { id, contractAddress });
dispatch({ type: CREATE_CONTRACT_ADDRESS, payload: response.data });
};
这是我尝试过的另一种方法,输出仍然相同:
//ACTION CREATOR V2
export const createOrgAndContract = (id) => async (dispatch, getState) => {
const account = await getState().web3connect.account;
console.log(account);
const createContract = await orgFactory.methods.createOrg(id).send({ from: account });
const contractAddress = createContract.events.orgCreated.returnValues.newAddress;
const response = await localDB.post(`/orgs`, { id, contractAddress });
dispatch({ type: CREATE_CONTRACT_ADDRESS, payload: response.data });
};
这是redux商店中的web3connect.account对象(如果我用这个地址替换“account”,一切都会很好):
这是我得到的错误
index.js:756 Uncaught (in promise) Error: No "from" address specified in neither the given options, nor the default options.
有人知道为什么这个变量在web3.js中不符合“发件人”地址的条件吗
index.js:756 Uncaught (in promise) Error: No "from" address specified in neither the given options, nor the default options.