我试图将props对象(在redux存储中保存的合同地址)传递给动作创建者,并将该props对象用作“发件人:”地址。但是,如果我没有手动传递地址的原始字符串,则会收到“指定的地址不存在”
我已经通过了简单的讲话,并且动作创建者的工作很棒。每当我给它变量时。我得到了错误。
//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”,则一切正常):
{
account: '0xB59EaB6A9C3AAC2dba42491502A0699c7b03A857'
}
这是我得到的错误
index.js:756 Uncaught (in promise) Error: No "from" address specified in neither the given options, nor the default options.
有人知道为什么这个变量不符合web3.js中的“发件人”地址吗?